Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit 4125b19

Browse files
hkielOpenModelica-Hudson
authored andcommitted
fix for Python3
remove redundant code optimize string compare Belonging to [master]: - #2778
1 parent 83d2116 commit 4125b19

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

Examples/ConvertBuildingsReferenceToCSV.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ def main():
143143
parser.add_option("--input-dir", help="Directory containing .txt reference files in the Buildings package format", type="string", dest="input_dir", default=os.path.abspath('.'))
144144
parser.add_option("--output-dir", help="Directory to generate csv-files in", type="string", dest="output_dir", default=os.path.abspath('.'))
145145
(options, args) = parser.parse_args()
146-
if len(args)<>0:
146+
if len(args)!=0:
147147
parser.error('This program does not take positional arguments')
148148
convertDir(options.input_dir,options.output_dir)
149149
if __name__ == '__main__':

Examples/GenerateDoc.mos

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ def linkreplace(link,filepath):
339339
result = regex.sub(repl,result)
340340
except:
341341
pass
342-
if result <> link and not rehttp.match(result):
342+
if result is not link and not rehttp.match(result):
343343
links.write('%s!%s\\n' % (filepath,ignorebookmark.sub(r'\\1',result)))
344344
return result
345345

@@ -349,7 +349,7 @@ for filepath in sorted(glob.glob('*.html')):
349349
# sys.stdout.write(tag) # not much point in writing the tags to stdout
350350
sys.stderr.write(tag)
351351
pid = sub.call(['tidy', '-utf8', '-modify', '-asxhtml', '--add-xml-decl', 'yes', '-quiet', filepath])
352-
if pid <> 2:
352+
if pid != 2:
353353
with open(filepath,'r') as html_file:
354354
soup = BeautifulSoup(html_file, fromEncoding='utf-8')
355355
for a in soup.findAll('a'):
@@ -500,7 +500,7 @@ def update(subst):
500500
patched = orig
501501
for s in subst.items():
502502
patched = re.sub('\\\\b'+s[0],s[1],patched)
503-
if patched != orig:
503+
if patched is not orig:
504504
with open (file, 'w' ) as f: f.write(patched)
505505
return
506506

@@ -540,19 +540,14 @@ system("mkdir -p " + dirs);
540540
system("cp '" + py + "' '" + self + "' .");
541541
"tar";
542542
dirs;
543-
cmd := "find . Icons -maxdepth 1 \\( -name '*.html' -o -name '*.svg' \\) -print0 | tar cJf ModelicaDocumentation.tar.xz --dereference --null style.css " + dirs + " GenerateDoc.mos generate_icons.py fix-case-sensitive.py FindFiles.log tidy.filtered tidy.links -T -";
543+
cmd := "find . Icons -maxdepth 1 \\( -name '*.html' -o -name '*.svg' \\) -print | tar cJf ModelicaDocumentation.tar.xz --dereference style.css " + dirs + " GenerateDoc.mos generate_icons.py fix-case-sensitive.py FindFiles.log tidy.filtered tidy.links -T -";
544544
system(cmd);
545545
getErrorString();
546546

547547
// Make zip (case-insensitive)
548548
system("python ./fix-case-sensitive.py");
549-
"FindFiles.sh";
550-
system("bash FindFiles.sh");
551549
system("rm -f ModelicaDocumentation.zip");
552-
system("mkdir -p " + dirs);
553-
system("cp '" + py + "' '" + self + "' .");
554-
"tar";
555-
dirs;
550+
"zip";
556551
cmd := "find . -maxdepth 1 -name '*.html' -print | zip -qr ModelicaDocumentation.zip style.css -@ Icons " + dirs + " GenerateDoc.mos generate_icons.py fix-case-sensitive.py FindFiles.log tidy.filtered tidy.links";
557552
system(cmd);
558553
getErrorString();

0 commit comments

Comments
 (0)