quotes

pyyaml and using quotes for strings only

柔情痞子 提交于 2019-12-01 16:15:19
I have the following YAML file: --- my_vars: my_env: "dev" my_count: 3 When I read it with PyYAML and dump it again, I get the following output: --- my_vars: my_env: dev my_count: 3 The code in question: with open(env_file) as f: env_dict = yaml.load(f) print(yaml.dump(env_dict, indent=4, default_flow_style=False, explicit_start=True)) I tried using the default_style parameter: with open(env_file) as f: env_dict = yaml.load(f) print(yaml.dump(env_dict, indent=4, default_flow_style=False, explicit_start=True, default_style='"')) But now I get: --- "my_vars": "my_env": "dev" "my_count": !!int "3

pyyaml and using quotes for strings only

瘦欲@ 提交于 2019-12-01 15:03:47
问题 I have the following YAML file: --- my_vars: my_env: "dev" my_count: 3 When I read it with PyYAML and dump it again, I get the following output: --- my_vars: my_env: dev my_count: 3 The code in question: with open(env_file) as f: env_dict = yaml.load(f) print(yaml.dump(env_dict, indent=4, default_flow_style=False, explicit_start=True)) I tried using the default_style parameter: with open(env_file) as f: env_dict = yaml.load(f) print(yaml.dump(env_dict, indent=4, default_flow_style=False,

CSV parser in JAVA, double quotes in string (SuperCSV, OpenCSV)

十年热恋 提交于 2019-12-01 10:44:52
all day I've been searching how to resolve this probem and nothing... I want to write function, which convert CSV file to collection of lists (of strings). Here is this function: public Collection<? extends List<String>> parse() throws IOException { Collection<List<String>> collectionOfLists = new ArrayList<List<String>>(); CsvListReader parser = new CsvListReader(Files.newBufferedReader(pathToFile, StandardCharsets.UTF_8), CsvPreference.EXCEL_PREFERENCE); List<String> row; while( (row = parser.read()) != null) collectionOfLists.add(row); return collectionOfLists; } public static String

CSV parser in JAVA, double quotes in string (SuperCSV, OpenCSV)

ε祈祈猫儿з 提交于 2019-12-01 08:54:20
问题 all day I've been searching how to resolve this probem and nothing... I want to write function, which convert CSV file to collection of lists (of strings). Here is this function: public Collection<? extends List<String>> parse() throws IOException { Collection<List<String>> collectionOfLists = new ArrayList<List<String>>(); CsvListReader parser = new CsvListReader(Files.newBufferedReader(pathToFile, StandardCharsets.UTF_8), CsvPreference.EXCEL_PREFERENCE); List<String> row; while( (row =

Building command strings using variables with various quote levels and spaces

≡放荡痞女 提交于 2019-12-01 08:39:53
I have a script that runs curl . I want to be able to optionally add a -H parameter, if a string isn't empty. What's complex is the levels of quoting and spaces. caption="Test Caption" if [ "${caption}" != "" ]; then CAPT=-H "X-Caption: ${caption}" fi curl -A "$UA" -H "Content-MD5: $MD5" -H "X-SessionID: $SID" -H "X-Version: 1" $CAPT http://upload.example.com/$FN The idea is that the CAPT variable is either empty, or contains the desired -H header in the same form as the others, e.g., -H "X-Caption: Test Caption" The problem is when run, it interprets the assignment as a command to be executed

Building command strings using variables with various quote levels and spaces

爷,独闯天下 提交于 2019-12-01 06:46:24
问题 I have a script that runs curl . I want to be able to optionally add a -H parameter, if a string isn't empty. What's complex is the levels of quoting and spaces. caption="Test Caption" if [ "${caption}" != "" ]; then CAPT=-H "X-Caption: ${caption}" fi curl -A "$UA" -H "Content-MD5: $MD5" -H "X-SessionID: $SID" -H "X-Version: 1" $CAPT http://upload.example.com/$FN The idea is that the CAPT variable is either empty, or contains the desired -H header in the same form as the others, e.g., -H "X

How does Google Closure Compiler handle quotes (string literals)?

雨燕双飞 提交于 2019-12-01 00:40:48
The question 'How does Google Closure Compiler handle quotes (string literals)?' could also be re-phrased like: Why does Closure replace/swap single quotes with double quotes? How does Closure decide what quote- formatting/style to use? (How) can I change this (default) behavior? Note 1: this question is not about why Closure (or some other minifiers) have chosen to prefer double quotes (as is asked here and here ). Note 2: this question is not about single vs double quote discussions, however some understanding what GCC does to our code (and why) is rather useful! It is often stated that (or

Use single quote or double quote for strings in EL

随声附和 提交于 2019-11-30 22:37:15
问题 <ui:repeat value="#{coreGridBean.heroBeanList}" var="hero" offset="0" step="1" size="#{hero.size}" varStatus="status"> <tr class="#{status.even ? 'evenColumn' : 'oddColumn'}"> <td>#{status.index}</td> <td>#{hero.id}</td> <td>#{hero.race}</td> <td>#{hero.name}</td> </tr> </ui:repeat> I wonder whether the usage of class="#{status.even ? 'evenColumn' : 'oddColumn'}" is correct. I feel a bit guilty of using single quotes instead of double quotes. But in this case, double quote fails, single quote

Why does $@ work different from most other variables in bash?

不羁岁月 提交于 2019-11-30 21:24:26
The $@ variable seems to maintain quoting around its arguments so that, for example: $ function foo { for i in "$@"; do echo $i; done } $ foo herp "hello world" derp herp hello world derp I am also aware that bash arrays, work the same way: $ a=(herp "hello world" derp) $ for i in "${a[@]}"; do echo $i; done herp hello world derp What is actually going on with variables like this? Particularly when I add something to the quote like "duck ${a[@]} goose". If its not space separated what is it? Usually, double quotation marks in Bash mean "make everything between the quotation marks one word,

Regular expression to match escaped characters (quotes)

雨燕双飞 提交于 2019-11-30 19:06:08
I want to build a simple regex that covers quoted strings, including any escaped quotes within them. For instance, "This is valid" "This is \" also \" valid" Obviously, something like "([^"]*)" does not work, because it matches up to the first escaped quote. What is the correct version? I suppose the answer would be the same for other escaped characters (by just replacing the respective character). By the way, I am aware of the "catch-all" regex "(.*?)" but I try to avoid it whenever possible, because, not surprisingly, it runs somewhat slower than a more specific one. The problem with all the