I'm having trouble excluding test files from my glob expression as follows :
I have this list of files
./app/tags.ts
./app/tag.ts
./app/status.ts
./app/bar/{foo}/baz.ts
./app/.hidden.ts
./app/_hidden.ts
./app/foo_dir/.hidden.ts
./app/some/testing_should_be_hidden.test.ts
I'm trying to exclude everything that starts with a '.' or starts with a '_' or includes a '.test' in the filename
so far this is what I tried :
Glob file pattern excluding node_modules
with my expression :
./**/[!._]*^(?!*test).{ts,js}
but It didn't work, however using:
./**/[!._]*.{ts,js}
excludes the 'hidden' files but not the test one
FYI : test is available here :
https://www.digitalocean.com/community/tools/glob?comments=false&glob=.%2F%2A%2A%2F%5B%21._%5D%2A%5E%28%3F%21%2Atest%29.%7Bts%2Cjs%7D&matches=false&tests=.%2Fapp%2Ftags.ts&tests=.%2Fapp%2Fgame%2F%7BgameId%7D%2Fclip.ts&tests=.%2Fapp%2F.hidden.ts&tests=.%2Fapp%2F_hidden.ts&tests=.%2Fapp%2Fgame%2F.hidden.ts&tests=.%2Fapp%2Fsome%2Ftesting.test.ts
So far this worked for me :
./**/[!._]!(*.test).{ts,js}
Can anyone explain this to me vs :
./**/[!._]*!(*.test).{ts,js}
Related
I am comparing two folders using python dircmp module from filecmp. I am then obtaining the result using report_full_closure(). I would like to generate a neat side by side comparison in HTML format of the comparison(example below). Is there an easy way to generate the report other than creating the HTML layout from scratch and parsing the output file line by line?
from filecmp import dircmp
dcmp = dircmp('dir_1', 'dir_2')
dcmp.report_full_closure()
Output:
diff dir_1 dir_2
Only in dir_1 : ['A.txt']
Only in dir_2 : ['Example.txt', 'flights.txt']
Identical files : ['gitignore_global.txt']
Common subdirectories : ['dir_1_1']
diff dir_1\dir_1_1 dir_2\dir_1_1
Only in dir_2\dir_1_1 : ['tasks.bin']
Identical files : ['IMG_20220225_0001.pdf']
Desired output:
Something similar to the beyondcompare HTML output below:
Thanks!
I have a widget where I wanted to convert a less file to an css file.
The conversion works perfectly. But now I want that the less files aren't published to the web/assets directory.
And here the Pain begins...
This is my code:
class BreadcrumbsAsset extends \yii\web\AssetBundle
{
public $css = [
'css/breadcrumbs.less',
];
public $js = [
'js/breadcrumbs.js',
];
public $depends = [
'yii\web\YiiAsset',
'yii\bootstrap\BootstrapAsset',
];
public $publishOptions = [
"only" => [
"css/*",
"js/*",
],
'except' => [
"doc/",
"*.less",
],
];
}
But with the except setting set the css file isn't generated.
Also when I try the other way around and set:
public $publishOptions = [
"only" => [
"css/*.css",
],
The css file isn't generated from the less file any more.
So how does this supose to work?
When the to options only and except are added for this this case:
https://github.com/yiisoft/yii2/issues/2511 (AssetBundle should not publish .less or .coffee files)
https://github.com/yiisoft/yii2/issues/8566 (AssetManager support for choosing file/dir to be publish)
The Publishoptions are descriped like this:
only: array, list of patterns that the file paths should match if they want to be copied.
except: array, list of patterns that the files or directories should match if they want to be excluded from being copied.
And in the Filehelper which is used for the File Publish the except and only are descriped like this (from the Yii2 Filehelper Source):
- `except`: array, list of patterns excluding from the results matching file or directory paths.
Patterns ending with slash ('/') apply to directory paths only, and patterns not ending with '/'
apply to file paths only. For example, '/a/b' matches all file paths ending with '/a/b';
and `.svn/` matches directory paths ending with `.svn`.
If the pattern does not contain a slash (`/`), it is treated as a shell glob pattern
and checked for a match against the pathname relative to `$dir`.
Otherwise, the pattern is treated as a shell glob suitable for consumption by `fnmatch(3)`
`with the `FNM_PATHNAME` flag: wildcards in the pattern will not match a `/` in the pathname.
For example, `views/*.php` matches `views/index.php` but not `views/controller/index.php`.
A leading slash matches the beginning of the pathname. For example, `/*.php` matches `index.php` but not `views/start/index.php`.
An optional prefix `!` which negates the pattern; any matching file excluded by a previous pattern will become included again.
If a negated pattern matches, this will override lower precedence patterns sources. Put a backslash (`\`) in front of the first `!`
for patterns that begin with a literal `!`, for example, `\!important!.txt`.
Note, the '/' characters in a pattern matches both '/' and '\' in the paths.
- `only`: array, list of patterns that the file paths should match if they are to be returned. Directory paths
are not checked against them. Same pattern matching rules as in the `except` option are used.
If a file path matches a pattern in both `only` and `except`, it will NOT be returned.
So how should this only and except settings work?
Or is this a Bug?
Forgot to mention that of course I have the newest yii2 version installed (the only and except settings for publishOptions were introduced with yii 2.0.6)
I have this path in my react gulpfile:
var path = {
HTML: 'src/index.html',
ALL: ['src/js/*.js', 'src/js/**/*.js', 'src/index.html'],
JS: ['src/js/*.js', 'src/js/**/*.js'],
MINIFIED_OUT: 'build.min.js',
DEST_SRC: 'dist/src',
DEST_BUILD: 'dist/build',
DEST: 'dist'
};
What is the double glob character?
I know what the single glob is... but what is the double?
single glob
It's almost the same as the single asterisk but may consist of multiple directory levels.
In other words, while /x/*/y will match entries like:
/x/a/y
/x/b/y
and so on (with only one directory level in the wildcard section), the double asterisk /x/**/y will also match things like:
/x/any/number/of/levels/y
with the concept of "any number of levels" also including zero (in other words, /x/**/y will match /x/y as one of its choices).
As an aside, as much as I hate to credit the mainframe with anything, I believe this has been used since the earlist days of MVS to allow selection of datasets at multiple levels :-)
** matches any character including a forward-slash /
* matches any character except a forward-slash (to match just the file or directory name)
It's usually used to indicate any number of subdirectories. So
src/js/**/*.js
Would match
src/js/files/*.js
src/js/more-files/*.js
etc
etc
Like Grunt, the double ** is saying, "Look in all the subfolders
within js and for all of the .js files."
You can actually refer here for the same:
https://www.codefellows.org/blog/quick-intro-to-gulp-js
I'm using gulp building my development workflow. Gulp and its plugins use glob heavily.
I'm confused about the differences between the followings:
directory/
directory/*
directory/**
directory/**/*
I'm not able to make gulp do the things I expect.
Grunt has a pretty good explanation of how globs work http://gruntjs.com/configuring-tasks#globbing-patterns
* matches any number of characters, but not /
** matches any number of characters, including /, as long as it's the only thing
in a path part. So a/**/b will match a/x/y/b, but a/**b will not.
directory/ = this isn't a glob and would evaluate as expected.
directory/* = will match anything in the directory, but not sub-directories.
directory/** = will match anything in the directory and all subdirectories.
directory/**/* = will match anything in the directory and all subdirectories.
(good for adding a prefix like an extension to the end)
In http://www.githubarchive.org/ that Ilya Grigorik has provided ,I found that in many gz files , some consecutive events are logged to same file .
for example in 2011-03-15-21.json.gz
To get the above do :
wget http://data.githubarchive.org/2011-03-15-21.json.gz
In this gz for example if you search for id 1484832 , you can find that the 2 consecutive events(jsons) are in same line
see
http://codebeautify.org/jsonviewer/2cb891
the two jsons in same line is a combination of
http://codebeautify.org/jsonviewer/c7e18e
and
http://codebeautify.org/jsonviewer/945d56
.
What is the impact ?
when I was loading each line and loading it with python's(why python ? because I felt python is comfortable in dealing with jsons) json.loads it said it was invalid as it was a combination of two jsons .
Question :
1) How did you solve these kind of bugs when you processed that github archive data ?
2) I already have the data in my local . so how can I overcome this problem . Shall I write code specific to this case to overcome ?
the code i wrote was like
jsonlist = line.split('}{')
json.loads(jsonlist[0] + '}', "ISO-8859-1") # load and navigate through this json
json.loads('{' + jsonlist[1], "ISO-8859-1") # load and navigate through this json
I got the solution here
1) How did you solve these kind of bugs when you processed that github archive data ?
https://github.com/vadasg/githubarchive-parser/blob/master/src/FixGitHubArchiveDelimiters.rb
. This script removes the problems of two or more events appearing on the same line .
so now after running this script the jsons appear in different lines .
2) I already have the data in my local . so how can I overcome this problem . Shall I write code specific to this case to overcome ? the code i wrote was like
This script removes the necessity to write the code I mentioned above .
Note :
Related issues found on the github archive project in github
https://github.com/igrigorik/githubarchive.org/issues/53
https://github.com/igrigorik/githubarchive.org/issues/17
WARNING :
When I was running this script I got an error related to the encoding used . Because by default the Yajl::Parser.parse(jsonInputFile)
line checks if characters it parses adheres to UTF-8 encoding ,if not it will throw errors .
As github data also contains non UTF-8 characters , this error will be thrown in our case too. So to bypass that problem(or may be a fix) I put it as
Yajl::Parser.parse(jsonInputFile, :check_utf8 => false)
for doubts refer docs: http://rdoc.info/github/brianmario/yajl-ruby/Yajl/Parser.parse