Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, filing_number, is_paper=False, base_url="http://docquery.fec.gov/dcdev/posted", local_copy=None):
#local_copy is an absolute path to a local copy of the filing, useful for testing
#or mucking around while offline.
init(autoreset=True)
print Style.BRIGHT + Fore.MAGENTA + "Getting filing " + Style.BRIGHT + Fore.YELLOW + "%s" % filing_number
self.document_base_url = base_url
self.version = None
self.filing_lines = []
self.is_amendment = None
self.amends_filing = None
self.page_read = None
self.headers = {}
self.headers_list = []
self.use_new_delimiter = True
self.csv_reader = None
self.filing_number = filing_number
self.is_paper = is_paper
# colors style text:
sd = Style.DIM
sn = Style.NORMAL
sb = Style.BRIGHT
sf = Style.RESET_ALL
else:
init(autoreset=True)
# colors foreground text:
fc = Fore.CYAN
fg = Fore.GREEN
fw = Fore.WHITE
fr = Fore.RED
fb = Fore.BLUE
fy = Fore.YELLOW
fm = Fore.MAGENTA
ff = Fore.RESET
# colors background text:
bc = Back.CYAN
bg = Back.GREEN
bw = Back.WHITE
br = Back.RED
bb = Back.BLUE
by = Back.YELLOW
bm = Back.MAGENTA
bf = Back.RESET
# colors style text:
sd = Style.DIM
sn = Style.NORMAL
sb = Style.BRIGHT
sf = Style.RESET_ALL
# HEADER = '\033[95m'
# OKBLUE = '\033[94m'
# OKGREEN = '\033[92m'
# WARNING = '\033[93m'
# FAIL = '\033[91m'
# ENDC = '\033[0m'
# BOLD = '\033[1m'
# UNDERLINE = '\033[4m'
init()
version = "0.1.3"
class UArmCmd(Cmd):
help_msg = Style.BRIGHT + Fore.MAGENTA + "Shortcut:" + Fore.RESET + Style.RESET_ALL + "\n"
help_msg += "Quit: " + Style.BRIGHT + Fore.RED + "Ctrl + D" + Fore.RESET + Style.RESET_ALL
help_msg += ", or input: " + Back.BLACK + Fore.WHITE + "quit" + Fore.RESET + Style.RESET_ALL + "\n"
help_msg += "Clear Screen: " + Style.BRIGHT + Fore.RED + "Ctrl + L" + Fore.RESET + Style.RESET_ALL
ON_OFF = ['on', 'off']
FIRMWARE =['version', 'force', 'upgrade']
SERVO_STATUS = ['attach', 'detach']
prompt = ">>> "
intro = "Welcome to use {}uArm Command Line{} - v{}\n"\
.format(Fore.YELLOW, Fore.RESET, version)
intro += help_msg
intro += "\n\n"
from tqdm import tqdm
display = print
FG = 0
BG = 1
# TODO: create a set of HTML color to allows richer display in colab
colors = {
'black': [Fore.BLACK, Back.BLACK],
'red': [Fore.RED, Back.RED],
'green': [Fore.GREEN, Back.GREEN],
'yellow': [Fore.YELLOW, Back.YELLOW],
'blue': [Fore.BLUE, Back.BLUE],
'magenta': [Fore.MAGENTA, Back.MAGENTA],
'cyan': [Fore.CYAN, Back.CYAN],
'white': [Fore.WHITE, Back.WHITE],
}
styles = {
"dim": Style.DIM,
"normal": Style.NORMAL,
"bright": Style.BRIGHT,
"reset": Style.RESET_ALL
}
# Shorthand functions
def info(text, render=1):
""" display a info
loc = getLocation(s)
if loc is None:
return
# Gets current date and time using TimeZoneDB API
send_url = (
"http://api.timezonedb.com/v2/get-time-zone?"
"key=BFA6XBCZ8AL5&format=json"
"&by=position&lat={:.6f}&lng={:.6f}".format(*loc)
)
r = requests.get(send_url)
j = json.loads(r.text)
time = j['formatted']
self.dst = j['dst']
# Prints current date and time as YYYY-MM-DD HH:MM:SS
print("{COLOR}The current date and time in {LOC} is: {TIME}{COLOR_RESET}"
.format(COLOR=Fore.MAGENTA, COLOR_RESET=Fore.RESET,
LOC=str(s).title(), TIME=str(time)))
bar_format = \
[
"Maven build: ",
get_colour(Fore.YELLOW),
progressbar.Percentage(),
get_colour(Fore.RESET),
" ",
progressbar.Counter(format='(%(value)d of %(max_value)d)'),
get_colour(Fore.LIGHTGREEN_EX),
progressbar.Bar(marker="\u2588"),
get_colour(Fore.RESET),
" ",
progressbar.Timer(),
" ",
get_colour(Fore.MAGENTA),
progressbar.AbsoluteETA(format='Finishes: %(eta)s', format_finished='Finished at %(eta)s')
if absolute_time else progressbar.AdaptiveETA(),
get_colour(Fore.RESET)
]
def ansi_length(o):
ansi_occ = re.findall(r'\x1B\[[0-?]*[ -/]*[@-~]', o)
ansi_len = 0
for occ in ansi_occ:
ansi_len += len(occ)
return len(o) - ansi_len
def match():
count = 0
def magenta(s: str) -> str: # pragma: no cover
"""Magenta color string if tty
Args:
s (str): String to color
Returns:
str: Colored string
Examples:
>>> from chepy.modules.internal.colors import magenta
>>> print(MAGENTA("some string"))
"""
if sys.stdout.isatty():
return Fore.MAGENTA + s + Fore.RESET
else:
return s
def magenta():
if not TextColor._NoColor:
print(Fore.MAGENTA,end='')
import numexpr as ne2
import numba
try:
from matplotlib import use
use('Qt5Agg')
import matplotlib.pyplot as plt
PLT = True
except ImportError:
PLT = False
RED = 0
PURPLE = -8
_COLOR_MAG = { 0: Fore.LIGHTRED_EX, -1: Fore.RED, -2: Fore.LIGHTYELLOW_EX,
-3: Fore.YELLOW, -4: Fore.LIGHTGREEN_EX, -5: Fore.GREEN,
-6: Fore.LIGHTBLUE_EX, -7: Fore.BLUE, -8: Fore.MAGENTA }
class Case(object):
_MAX_ARGS = 4
_C_BENCH = {0:'prepare_threads', 1:'run_preamble', 2:'magic_broadcast',
3:'npyiter_con', 4:'barrier_init', 5:'task_barrier_final',
6:'unlock_global', 7:'run_clean', 8:'release_gil',
9:'reacquire_gil',
50: 'cobj_init' }
_C_THREADS = {150:'thread_init', 200:'thread_tasks', 250:'thread_final'}
def initZeros(self):
# return [0.0]*self.tries
return np.zeros(self.tries, dtype='float64')
def __init__(self, expr, size, dtype, tries=1,
keypress.DOWN: Board.DOWN,
keypress.LEFT: Board.LEFT,
keypress.RIGHT: Board.RIGHT,
keypress.SPACE: Board.PAUSE,
}
__is_windows = os.name == 'nt'
COLORS = {
2: Fore.GREEN,
4: Fore.BLUE + Style.BRIGHT,
8: Fore.CYAN,
16: Fore.RED,
# Don't use MAGENTA directly; it doesn't display well on Windows.
# see https://github.com/bfontaine/term2048/issues/24
32: Fore.MAGENTA + Style.BRIGHT,
64: Fore.CYAN,
128: Fore.BLUE + Style.BRIGHT,
256: Fore.MAGENTA + Style.BRIGHT,
512: Fore.GREEN,
1024: Fore.RED,
2048: Fore.YELLOW,
# just in case people set an higher goal they still have colors
4096: Fore.RED,
8192: Fore.CYAN,
}
# see Game#adjustColors
# these are color replacements for various modes
__color_modes = {
'dark': {
Fore.BLUE: Fore.WHITE,