Skip to content

Commit

Permalink
black
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Feb 13, 2022
1 parent ad3e718 commit 673ac88
Show file tree
Hide file tree
Showing 8 changed files with 795 additions and 800 deletions.
354 changes: 170 additions & 184 deletions check_https.py

Large diffs are not rendered by default.

28 changes: 13 additions & 15 deletions checkdups.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,32 +7,34 @@
from __future__ import (
absolute_import,
division,
print_function # ,
print_function, # ,
# unicode_literals
)

import datetime

# import fnmatch
import glob

# import json
import re
import os
import subprocess
import sys

path = os.environ['PATH']
path = os.environ["PATH"]

paths = path.split(';')
paths = path.split(";")

seen_paths = {}

exes = {}

include_dirs = [] # ['c:\\bin']
exclude_dirs = [
r'%USERPROFILE%\scoop\apps\imagemagick\current',
r'%SystemDrive%\GnuWin32\bin',
r'%USERPROFILE%\scoop\apps\git\current\mingw64\bin'
r"%USERPROFILE%\scoop\apps\imagemagick\current",
r"%SystemDrive%\GnuWin32\bin",
r"%USERPROFILE%\scoop\apps\git\current\mingw64\bin",
]

for i, _dir in enumerate(exclude_dirs):
Expand Down Expand Up @@ -97,20 +99,16 @@
continue
print("%s:" % file)
for path in exes[file]:
full = path + '\\' + file
full = path + "\\" + file
# q = '"%s"' % full
# print("q=%s" % q)
out = 'n/a'
if re.search('(com|dll|exe)$', file) is not None:
p = subprocess.Popen(
['sigcheck.exe', '-nobanner', '-n', full],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
out = "n/a"
if re.search("(com|dll|exe)$", file) is not None:
p = subprocess.Popen(["sigcheck.exe", "-nobanner", "-n", full], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = p.communicate()
out = out.strip()
mtime = os.path.getmtime(full)
out += datetime.datetime.fromtimestamp(mtime).strftime(
' (%Y-%m-%d %H:%M:%S)')
out += datetime.datetime.fromtimestamp(mtime).strftime(" (%Y-%m-%d %H:%M:%S)")
print(" %*s: %s" % (-max_path, path, out))

sys.exit(0)
18 changes: 9 additions & 9 deletions checkver.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import (
absolute_import,
division,
print_function # ,
print_function, # ,
# unicode_literals
)

Expand All @@ -21,9 +21,9 @@
specs.pop(0)

if len(specs) == 0:
specs = ['*.json']
specs = ["*.json"]

for file in os.listdir('bucket'):
for file in os.listdir("bucket"):
accept = False
for spec in specs:
if fnmatch.fnmatch(file, spec):
Expand All @@ -33,18 +33,18 @@
if not accept:
continue

with open(file, 'r') as f:
with open(file, "r") as f:
j = json.load(f)
row = {}
(name, ext) = os.path.splitext(os.path.basename(file))
if re.search('^_', name):
if re.search("^_", name):
continue
if 'checkver' in j:
if "checkver" in j:
continue
if 'homepage' in j:
url = j['homepage']
if "homepage" in j:
url = j["homepage"]
else:
url = 'https://www.google.com/search?q=' + name
url = "https://www.google.com/search?q=" + name
print("%s: %s" % (name, url))

sys.exit(0)
32 changes: 17 additions & 15 deletions find-conflicts.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from __future__ import (
absolute_import,
division,
print_function # ,
print_function, # ,
# unicode_literals
)

Expand All @@ -17,24 +17,26 @@
import sys

from jsoncomment import JsonComment

# from jsonschema import validate


def decode(s):
""" doc me """
for encoding in 'utf-8-sig', 'utf-16':
"""doc me"""
for encoding in "utf-8-sig", "utf-16":
try:
return s.decode(encoding)
except UnicodeDecodeError:
continue
return s.decode('latin-1')
return s.decode("latin-1")


scoop_root = '%USERPROFILE%/scoop'
scoop_root = "%USERPROFILE%/scoop"
scoop_root = os.path.expandvars(scoop_root)
buckets_root = scoop_root + '/buckets'
buckets_root = scoop_root + "/buckets"

buckets = [
scoop_root + '/apps/scoop/current/bucket',
scoop_root + "/apps/scoop/current/bucket",
# buckets_root + '/extras',
# buckets_root + '/nirsoft',
# buckets_root + '/rasa'
Expand All @@ -45,28 +47,28 @@ def decode(s):
amap = {}

for bucket in buckets:
for json_file in glob.glob(bucket + '/*.json'):
with open(json_file, 'rb') as f:
for json_file in glob.glob(bucket + "/*.json"):
with open(json_file, "rb") as f:
jstr = f.read()
jstr_no_bom = decode(jstr)
json_data = parser.loads(jstr_no_bom)
if 'bin' not in json_data:
if "bin" not in json_data:
continue
base = os.path.basename(json_file)
base = os.path.splitext(base)[0]
adir = os.path.basename(os.path.dirname(json_file))
repo = adir + '/' + base
bins = json_data['bin']
repo = adir + "/" + base
bins = json_data["bin"]
if len(bins) == 0:
continue
if type(bins).__name__ != 'list':
if type(bins).__name__ != "list":
bins = [bins]
if len(bins) == 0:
continue
if type(bins).__name__ != 'list':
if type(bins).__name__ != "list":
bins = [bins]
for abin in bins:
if type(abin).__name__ == 'list':
if type(abin).__name__ == "list":
if len(abin) > 1:
file = str(abin[1])
else:
Expand Down
91 changes: 47 additions & 44 deletions jsonfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,77 +12,81 @@
import sys

from jsoncomment import JsonComment

# from jsonschema import validate


def decode(s):
""" doc me """
"""doc me"""
if sys.version_info >= (3, 0):
return s

for encoding in 'utf-8-sig', 'utf-16':
for encoding in "utf-8-sig", "utf-16":
try:
return s.decode(encoding)
except UnicodeDecodeError:
continue
return s.decode('latin-1')
return s.decode("latin-1")


def touch(filename, mtime):
""" doc me """
with open(filename, 'a+'):
"""doc me"""
with open(filename, "a+"):
pass
os.utime(filename, (mtime, mtime))
return 0


def add(key, old, new):
""" doc me """
"""doc me"""
if key in old:
new[key] = old[key]
return new


file = sys.argv[1]
if file == 'schema.json':
if file == "schema.json":
sys.exit(0)
print('Updating %s' % file)
print("Updating %s" % file)

# mtime = os.path.getmtime(file)

with open(file, 'r') as f:
with open(file, "r") as f:
jstr = f.read()
jstr_no_bom = decode(jstr)

parser = JsonComment(json)
json_data = parser.loads(jstr_no_bom)

keys = [
'##',
'_comment',
'version',
'description',
'homepage',
'license',
'notes',
'depends',
'suggest',
'cookie',
'architecture',
'url',
'hash',
'innosetup',
'extract_dir',
'extract_to',
'pre_install',
'installer',
'post_install',
'uninstaller',
'bin',
'shortcuts',
'psmodule',
'env_add_path',
'env_set',
'persist',
'checkver',
'autoupdate',
"##",
"_comment",
"version",
"description",
"homepage",
"license",
"notes",
"depends",
"suggest",
"cookie",
"architecture",
"url",
"hash",
"innosetup",
"extract_dir",
"extract_to",
"pre_install",
"installer",
"post_install",
"uninstaller",
"bin",
"shortcuts",
"psmodule",
"env_add_path",
"env_set",
"persist",
"checkver",
"autoupdate",
]

old_json = json_data
Expand All @@ -96,17 +100,16 @@ def add(key, old, new):
pprint.pprint(old_json)
sys.exit(1)

new_data = json.dumps(
new_json, sort_keys=False, indent=4, separators=(',', ': '), ensure_ascii=False)
new_data = json.dumps(new_json, sort_keys=False, indent=4, separators=(",", ": "), ensure_ascii=False)
# new_data = new_data.encode('utf-8')
new_data += "\n"
with io.open(file + '.tmp', 'w', encoding='utf-8', newline='\r\n') as f:
with io.open(file + ".tmp", "w", encoding="utf-8", newline="\r\n") as f:
f.write(new_data)

if os.path.isfile(file + '.bak'):
os.remove(file + '.bak')
os.rename(file, file + '.bak')
os.rename(file + '.tmp', file)
if os.path.isfile(file + ".bak"):
os.remove(file + ".bak")
os.rename(file, file + ".bak")
os.rename(file + ".tmp", file)

# touch(file, mtime)

Expand Down
Loading

0 comments on commit 673ac88

Please sign in to comment.