Appease some flake8 linting.
This commit is contained in:
parent
3ff49e1a44
commit
0cb646fda0
12 changed files with 24 additions and 65 deletions
|
@ -19,8 +19,10 @@ def from_base(number, base, alphabet=None):
|
||||||
if number.count('.') > 1:
|
if number.count('.') > 1:
|
||||||
raise ValueError('Too many decimal points')
|
raise ValueError('Too many decimal points')
|
||||||
|
|
||||||
mixed_case = any(c in string.ascii_uppercase for c in alphabet) and \
|
mixed_case = (
|
||||||
|
any(c in string.ascii_uppercase for c in alphabet) and
|
||||||
any(c in string.ascii_lowercase for c in alphabet)
|
any(c in string.ascii_lowercase for c in alphabet)
|
||||||
|
)
|
||||||
if not mixed_case:
|
if not mixed_case:
|
||||||
alphabet = alphabet.upper()
|
alphabet = alphabet.upper()
|
||||||
number = number.upper()
|
number = number.upper()
|
||||||
|
@ -45,7 +47,6 @@ def from_base(number, base, alphabet=None):
|
||||||
if index < decimal_pos:
|
if index < decimal_pos:
|
||||||
power -= 1
|
power -= 1
|
||||||
value = alpha_dict[character] * (base ** power)
|
value = alpha_dict[character] * (base ** power)
|
||||||
#print(value)
|
|
||||||
result += value
|
result += value
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from voussoirkit import clipext
|
|
||||||
from voussoirkit import pipeable
|
from voussoirkit import pipeable
|
||||||
|
|
||||||
|
|
||||||
__VERSION__ = '0.0.1'
|
__VERSION__ = '0.0.1'
|
||||||
|
|
||||||
BYTE = 1
|
BYTE = 1
|
||||||
|
|
|
@ -1,13 +1,9 @@
|
||||||
import argparse
|
import argparse
|
||||||
import os
|
import os
|
||||||
import pyperclip
|
|
||||||
import requests
|
import requests
|
||||||
import sys
|
|
||||||
import time
|
|
||||||
import urllib
|
import urllib
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
# pip install voussoirkit
|
|
||||||
from voussoirkit import bytestring
|
from voussoirkit import bytestring
|
||||||
from voussoirkit import ratelimiter
|
from voussoirkit import ratelimiter
|
||||||
from voussoirkit import clipext
|
from voussoirkit import clipext
|
||||||
|
@ -72,7 +68,6 @@ def download_file(
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
verify_ssl=verify_ssl,
|
verify_ssl=verify_ssl,
|
||||||
)
|
)
|
||||||
#print(plan)
|
|
||||||
if plan is None:
|
if plan is None:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -291,7 +286,6 @@ class Progress1:
|
||||||
self.solid_char = '█'
|
self.solid_char = '█'
|
||||||
|
|
||||||
def step(self, bytes_downloaded):
|
def step(self, bytes_downloaded):
|
||||||
#print(self.limiter.balance)
|
|
||||||
percent = bytes_downloaded / self.total_bytes
|
percent = bytes_downloaded / self.total_bytes
|
||||||
percent = min(1, percent)
|
percent = min(1, percent)
|
||||||
if self.limiter.limit(1) is False and percent < 1:
|
if self.limiter.limit(1) is False and percent < 1:
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
import datetime
|
import datetime
|
||||||
import time
|
|
||||||
|
|
||||||
EPOCH = datetime.datetime(
|
EPOCH = datetime.datetime(
|
||||||
year=1993,
|
year=1993,
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import time
|
|
||||||
ESCAPE_SEQUENCES = {
|
ESCAPE_SEQUENCES = {
|
||||||
'\\': '\\',
|
'\\': '\\',
|
||||||
'"': '"',
|
'"': '"',
|
||||||
|
@ -83,7 +82,6 @@ class ExpressionTree:
|
||||||
if child.token in OPERATORS:
|
if child.token in OPERATORS:
|
||||||
childstring = '(%s)' % childstring
|
childstring = '(%s)' % childstring
|
||||||
children.append(childstring)
|
children.append(childstring)
|
||||||
#children = [str(child) for child in self.children]
|
|
||||||
|
|
||||||
if len(children) == 1:
|
if len(children) == 1:
|
||||||
return '%s %s' % (self.token, children[0])
|
return '%s %s' % (self.token, children[0])
|
||||||
|
@ -106,12 +104,10 @@ class ExpressionTree:
|
||||||
current = cls(token=tokens[0])
|
current = cls(token=tokens[0])
|
||||||
|
|
||||||
for token in tokens[1:]:
|
for token in tokens[1:]:
|
||||||
##print(' '*spaces, 'cur', current, current.token)
|
|
||||||
if isinstance(token, list):
|
if isinstance(token, list):
|
||||||
new = cls.parse(token, spaces=spaces+1)
|
new = cls.parse(token, spaces=spaces+1)
|
||||||
else:
|
else:
|
||||||
new = cls(token=token)
|
new = cls(token=token)
|
||||||
##print(' '*spaces, 'new', new)
|
|
||||||
|
|
||||||
if 0 == 1:
|
if 0 == 1:
|
||||||
pass
|
pass
|
||||||
|
@ -175,10 +171,7 @@ class ExpressionTree:
|
||||||
else:
|
else:
|
||||||
raise Exception('Expected new to be my operand or parent binary.')
|
raise Exception('Expected new to be my operand or parent binary.')
|
||||||
|
|
||||||
##print(' '*spaces, 'fin:', current.rootmost(), '\n')
|
|
||||||
|
|
||||||
current = current.rootmost()
|
current = current.rootmost()
|
||||||
##print('---', current)
|
|
||||||
return current
|
return current
|
||||||
|
|
||||||
def _evaluate(self, text, match_function=None):
|
def _evaluate(self, text, match_function=None):
|
||||||
|
@ -187,7 +180,6 @@ class ExpressionTree:
|
||||||
match_function = DEFAULT_MATCH_FUNCTION
|
match_function = DEFAULT_MATCH_FUNCTION
|
||||||
|
|
||||||
value = match_function(text, self.token)
|
value = match_function(text, self.token)
|
||||||
#print(self.token, value)
|
|
||||||
return value
|
return value
|
||||||
|
|
||||||
operator_function = OPERATOR_FUNCTIONS[self.token]
|
operator_function = OPERATOR_FUNCTIONS[self.token]
|
||||||
|
@ -319,7 +311,6 @@ def implied_tokens(tokens):
|
||||||
if skip_this:
|
if skip_this:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
#print('tk:', token, 'hu:', has_unary_operator, 'hb:', has_binary_operator, 'ho:', has_operand)
|
|
||||||
if isinstance(token, str) and token in OPERATORS:
|
if isinstance(token, str) and token in OPERATORS:
|
||||||
this_binary = token in BINARY_OPERATORS
|
this_binary = token in BINARY_OPERATORS
|
||||||
this_unary = not this_binary
|
this_unary = not this_binary
|
||||||
|
@ -370,7 +361,6 @@ def order_operations(tokens):
|
||||||
slice_end = None
|
slice_end = None
|
||||||
precedence_stack = []
|
precedence_stack = []
|
||||||
while index < len(tokens):
|
while index < len(tokens):
|
||||||
#time.sleep(0.1)
|
|
||||||
token = tokens[index]
|
token = tokens[index]
|
||||||
try:
|
try:
|
||||||
precedence = PRECEDENCE.index(token)
|
precedence = PRECEDENCE.index(token)
|
||||||
|
@ -382,7 +372,6 @@ def order_operations(tokens):
|
||||||
continue
|
continue
|
||||||
precedence_stack.append(precedence)
|
precedence_stack.append(precedence)
|
||||||
|
|
||||||
|
|
||||||
if token in UNARY_OPERATORS:
|
if token in UNARY_OPERATORS:
|
||||||
slice_start = index
|
slice_start = index
|
||||||
slice_end = index + 2
|
slice_end = index + 2
|
||||||
|
@ -394,8 +383,6 @@ def order_operations(tokens):
|
||||||
elif precedence_stack[-2] < precedence_stack[-1]:
|
elif precedence_stack[-2] < precedence_stack[-1]:
|
||||||
slice_end = index
|
slice_end = index
|
||||||
|
|
||||||
#print(tokens, index, token, precedence_stack, slice_start, slice_end, sep=' || ')
|
|
||||||
|
|
||||||
if slice_start is None or slice_end is None:
|
if slice_start is None or slice_end is None:
|
||||||
index += 1
|
index += 1
|
||||||
continue
|
continue
|
||||||
|
@ -432,7 +419,6 @@ def sublist_tokens(tokens, _from_index=0, depth=0):
|
||||||
index = _from_index
|
index = _from_index
|
||||||
while index < len(tokens):
|
while index < len(tokens):
|
||||||
token = tokens[index]
|
token = tokens[index]
|
||||||
#print(index, token)
|
|
||||||
index += 1
|
index += 1
|
||||||
if token is PAREN_OPEN:
|
if token is PAREN_OPEN:
|
||||||
(token, index) = sublist_tokens(tokens, _from_index=index, depth=depth+1)
|
(token, index) = sublist_tokens(tokens, _from_index=index, depth=depth+1)
|
||||||
|
@ -466,7 +452,6 @@ def tokenize(expression):
|
||||||
tokens = []
|
tokens = []
|
||||||
for character in expression:
|
for character in expression:
|
||||||
if in_escape:
|
if in_escape:
|
||||||
#character = ESCAPE_SEQUENCES.get(character, '\\'+character)
|
|
||||||
in_escape = False
|
in_escape = False
|
||||||
|
|
||||||
elif character in {'(', ')'} and not in_quotes:
|
elif character in {'(', ')'} and not in_quotes:
|
||||||
|
@ -509,23 +494,6 @@ def tokenize(expression):
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
tests = [
|
tests = [
|
||||||
#'test you AND(1 OR "harrison ford") AND (where are you) AND pg',
|
|
||||||
#'(you OR "AND ME")',
|
|
||||||
#'(3 XOR 2 OR 4',
|
|
||||||
#'1 NOT OR AND (2 OR (3 OR 4) OR (5 OR 6)))',
|
|
||||||
#'3 OR (5 OR)',
|
|
||||||
#'1 AND(4 OR "5 6")OR \\(test) 2',
|
|
||||||
#'1 2 AND (3 OR 4)',
|
|
||||||
#'AND 2',
|
|
||||||
#'1 AND 2 AND ("3 7" OR 6)AND (4 OR 5)',
|
|
||||||
#'NOT 1 AND NOT (2 OR 3)',
|
|
||||||
#'1 AND 2 AND 3 AND 4',
|
|
||||||
#'NOT 1 AND 2 OR 3 OR (5 AND 6)',
|
|
||||||
#'5 OR 6 AND 7 OR 8',
|
|
||||||
#'1 OR 2 AND 3 AND 4 OR 5 AND 6 OR 7 OR 8 AND 9',
|
|
||||||
#'2 XOR 3 AND 4',
|
|
||||||
#'1 OR (2 OR 3 AND 4)',
|
|
||||||
#'NOT XOR 4 7'
|
|
||||||
'[sci-fi] OR [pg-13]',
|
'[sci-fi] OR [pg-13]',
|
||||||
'([sci-fi] OR [war]) AND [r]',
|
'([sci-fi] OR [war]) AND [r]',
|
||||||
'[r] XOR [sci-fi]',
|
'[r] XOR [sci-fi]',
|
||||||
|
|
|
@ -14,12 +14,14 @@ class Landmark:
|
||||||
def barsplit(chars):
|
def barsplit(chars):
|
||||||
wordlist = []
|
wordlist = []
|
||||||
wordbuff = []
|
wordbuff = []
|
||||||
|
|
||||||
def flush():
|
def flush():
|
||||||
if not wordbuff:
|
if not wordbuff:
|
||||||
return
|
return
|
||||||
word = fusk_join(wordbuff)
|
word = fusk_join(wordbuff)
|
||||||
wordlist.append(word)
|
wordlist.append(word)
|
||||||
wordbuff.clear()
|
wordbuff.clear()
|
||||||
|
|
||||||
for item in chars:
|
for item in chars:
|
||||||
if item == '|':
|
if item == '|':
|
||||||
flush()
|
flush()
|
||||||
|
|
|
@ -312,12 +312,10 @@ def get_path_casing(path):
|
||||||
|
|
||||||
imaginary_portion = input_path.absolute_path
|
imaginary_portion = input_path.absolute_path
|
||||||
imaginary_portion = imaginary_portion[len(cased):]
|
imaginary_portion = imaginary_portion[len(cased):]
|
||||||
#real_portion = os.path.normcase(cased)
|
|
||||||
#imaginary_portion = imaginary_portion.replace(real_portion, '')
|
|
||||||
imaginary_portion = imaginary_portion.lstrip(os.sep)
|
imaginary_portion = imaginary_portion.lstrip(os.sep)
|
||||||
cased = os.path.join(cased, imaginary_portion)
|
cased = os.path.join(cased, imaginary_portion)
|
||||||
cased = cased.rstrip(os.sep)
|
cased = cased.rstrip(os.sep)
|
||||||
if not os.sep in cased:
|
if os.sep not in cased:
|
||||||
cased += os.sep
|
cased += os.sep
|
||||||
return cased
|
return cased
|
||||||
|
|
||||||
|
@ -341,7 +339,6 @@ def glob_patternize(piece):
|
||||||
for character in piece:
|
for character in piece:
|
||||||
if character not in '![]':
|
if character not in '![]':
|
||||||
replacement = '[%s]' % character
|
replacement = '[%s]' % character
|
||||||
#print(piece, character, replacement)
|
|
||||||
piece = piece.replace(character, replacement, 1)
|
piece = piece.replace(character, replacement, 1)
|
||||||
break
|
break
|
||||||
return piece
|
return piece
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
import collections
|
|
||||||
import hashlib
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
@ -420,8 +419,11 @@ def copy_file(
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
data_chunk = source_handle.read(chunk_size)
|
data_chunk = source_handle.read(chunk_size)
|
||||||
except PermissionError as e:
|
except PermissionError as exception:
|
||||||
print(source)
|
if callback_permission_denied is not None:
|
||||||
|
callback_permission_denied(source, exception)
|
||||||
|
return [destination, 0]
|
||||||
|
else:
|
||||||
raise
|
raise
|
||||||
data_bytes = len(data_chunk)
|
data_bytes = len(data_chunk)
|
||||||
if data_bytes == 0:
|
if data_bytes == 0:
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
import os
|
|
||||||
|
|
||||||
class ExistingChild(Exception):
|
class ExistingChild(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue