Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pfuntner/toys
Browse files Browse the repository at this point in the history
  • Loading branch information
John Pfuntner committed Nov 20, 2024
2 parents 7f539ce + ca3f9f2 commit 900379a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion bin/table2json
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ else:
headers = []
data = []

regexp = re.compile('\|([^|]*)(?=\|)')
regexp = re.compile(r'\|([^|]*)(?=\|)')
# find heading row
while not headers:
line = stream.readline()
Expand Down
Empty file modified bin/vact.py
100644 → 100755
Empty file.
12 changes: 6 additions & 6 deletions bin/whatami
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def run(cmd, silent=False, strip_whitespace=False):

def parse_fixed_table(data):
ret = {}
data = data.replace('\r', '').splitlines()
data = data.replace(r'\r', '').splitlines()
log.debug('data: {data}'.format(**locals()))
if len(data) > 1:
headings = re.findall(r'\w+\s+', data[0])
Expand Down Expand Up @@ -165,7 +165,7 @@ def get_version():
origin https://github.com/pfuntner/gists.git (fetch)
origin [email protected]:pfuntner/toys.git (fetch)
"""
match = re.search('origin\s+[^:@]+[:@]/?/?([^/]+/.*)\.git\s+\(fetch\)', str(stdout))
match = re.search(r'origin\s+[^:@]+[:@]/?/?([^/]+/.*)\.git\s+\(fetch\)', str(stdout))
log.debug('`git remote -v` groups: {groups}'.format(groups=match.groups() if match else None))
if match:
ret = '{timestamp!s}, {repo}, {branch}, {commit}'.format(repo=match.group(1), **locals())
Expand Down Expand Up @@ -272,7 +272,7 @@ if 'win' in sys.platform.lower():
else:
total += bytes

free = extract('wmic os get freephysicalmemory', '(\d+)', lambda match: float(match.group(1))*1024)
free = extract('wmic os get freephysicalmemory', r'(\d+)', lambda match: float(match.group(1))*1024)

if total and free:
print('Free RAM: {free}/{total} {pcent:.2f}%'.format(free=human(free), total=human(total), pcent=100*free/total))
Expand Down Expand Up @@ -317,7 +317,7 @@ else:
# Linux
out = run('/sbin/ifconfig', silent=True)
if out:
adapter_regexp = re.compile('^(\w+):')
adapter_regexp = re.compile(r'^(\w+):')
ignore_adapter_regexp = re.compile('(lo|docker)')
attrs = {}
for line in out.splitlines():
Expand Down Expand Up @@ -354,9 +354,9 @@ else:

print('')

extract('free -b', '^Mem:\s+(\d+)\s+(\d+)\s+(\d+)', ram_usage, 'Free RAM')
extract('free -b', r'^Mem:\s+(\d+)\s+(\d+)\s+(\d+)', ram_usage, 'Free RAM')

extract('lscpu', '^Model name:\s+(.+)$', lambda match: match.group(1).strip(), 'CPU name')
extract('lscpu', r'^Model name:\s+(.+)$', lambda match: match.group(1).strip(), 'CPU name')
run('uptime', strip_whitespace=True)

pwd = os.getcwd()
Expand Down
2 changes: 1 addition & 1 deletion misc/.bashrc
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ alias truepath=truepath.py

# alias zip=unzip

alias vact='. vact.py'
alias vact='. $(vact.py)'

alias fixed2json='table.py -i fixed --headings -o json'
alias fixed2sep='table.py -i fixed --headings -o sep --sep \|'
Expand Down

0 comments on commit 900379a

Please sign in to comment.