What does this match pattern declaration in manifest.json file imply ?
I read from the following URL and can't find any results.
https://developer.chrome.com/extensions/declare_permissions
https://developer.chrome.com/extensions/match_patterns
Related
I want to try using this shutil.copy and my files got some symbolic characters inside its name, so I need to use this shutil.copy(src, dst, *, follow_symlinks=True) command. but the compiler keeps giving me the invalid syntax messages. I had google and didn't find any solution yet for this. anyone can point out what is wrong with my syntax? because I already tried to print out the files inside those directories and it is okay, the network shared folder also got the permission and so on. but don't know what is wrong with my syntax. help me. thanks
This is my current script
and here is the output I got
File "C:\Users\1000266946\Desktop\sa\we.py", line 17
shutil.copy( files, parse_destination_path, * , follow_symlinks = True)
^
SyntaxError: invalid syntax
[Finished in 0.3s]
first of all: the asterisk as you show it can be used in function definitions to define keyword-only arguments (see e.g. here) - but you don't use it in a function call. So in shutil.copy(src, dst, *, follow_symlinks=True) in the docs, it tells you that follow_symlinks can only be used as a keyword argument, not as a positional argument.
second: take a look at the return value of os.listdir(). it returns only file names, without the path as noted in the docs. shutil.copy() however expects a full path, not only the filename. so what you could do is
for file in parse_source_file_list:
shutil.copy(os.path.join(parse_source_path, file), os.path.join(parse_destination_path, file))
further reading: you might also be interested in having a look at glob and pathlib for file handling purposes (docs here and here).
I'm trying to open the files whose name contains a pattern - which is the key value stored in a dictionary (key values in the dictionary are the patterns I'm trying to match in the file name).
I'm currently using glob.blob to match the pattern in the file name. The name of my dictionary is "xd". So, I want to implement something like this:
for key in xd :
for name in glob.glob(*key*):
file = open ('name','w')
I'm getting invalid syntax error here
I want to be able to open all the files which have the 'key' in their name and perform text addition in those files. Could someone please tell me if there is a way of doing this?
glob.glob() expects a str parameter, so you'll need to make a string out of the wildcards with key included. I'd also suggest opening files using with so you don't forget to close the file descriptor.
for key in xd:
for name in glob.glob(f"*{key}*"):
with open(name, 'w')
...
I'd love to know how to search for a string like join on any file in which at any level in the path a given word, workspace for example, is present.
So it would match all the following:
app/js/workspaces/foo.js
css/project_a/some-workspace-awesome-/bar.js
scripts/open-workspaces.sh
I tried this with using *workspace* (img for reference) however it only finds the last one of the examples given (only matches the file name).
Find -> Find in Project. This returns all paths and references to the keyword.
How can I match this error in the build with regex to locate line and file with result_line_regex & result_file_regex?
project4.dpr(9) Hint: H2164 Variable 'I' is declared but never used in 'Project3'
I have tried this but it won't work.
"result_file_regex": "^.*\\(.*)/.?(.*)$",
"result_line_regex": "^([^\\]*)\.(\w+)$",
As already mentioned in the comments, file_regex is the setting that gets passed to result_line_regex (have a look at the run() method signature of class ExecCommand in Packages/Default/exec.py).
A good regex in your case would be ^([\w-]+\.\w+)\((\d+)\). The first group captures something like my-file.ext and the second one the digit(s) in parentheses.
In order to set that expression in a string in the json file you need to escape each backslash with another backslash (\ is the escape character in strings), so it becomes:
"file_regex": "^([\\w-]+\\.\\w+)\\((\\d+)\\)"
Notice that the matched file has to be in the path of the file that is active when triggering the build system. If you want it to be relative to a certain path no matter where you trigger the build, you can also pass a working directory like:
"working_dir": "/path/to/my/source"
This will be set as result_base_dir in the output view.
I ONLY want to match
*://www.foo.com
with either no querystring like above, or any querystring:
*://www.foo.com/?*
Problem is, how do I match the first pattern above? My guess is I have to just match all paths then exclude all paths, then include the second pattern above.
Any better way to do this?
Your patterns are almost correct. The path name is required. Even when the omnibar shows www.foo.com, then the path is /.
*://www.foo.com/
*://www.foo.com/?*
Note: the last pattern matches /?test but not /index?test.
For more information, see Match patterns.