def __init__(self, subreddit): with open("config.yml", "r") as ymlconfig: config = yaml.load(ymlconfig) imgur_client_id = config["processing.config"]["imgur.config"][ "imgur_client_id"] imgur_app_secret = config["processing.config"]["imgur.config"][ "imgur_app_secret"] reddit_client_id = config["processing.config"]["reddit.config"][ "reddit_client_id"] reddit_app_secret = config["processing.config"]["reddit.config"][ "reddit_app_secret"] reddit_app_username = config["processing.config"]["reddit.config"][ "reddit_app_username"] reddit_app_password = config["processing.config"]["reddit.config"][ "reddit_app_password"] self._processing_templates = config["processing.config"][ "processing.path"]["sketches"] self._redditClass = redditpy.Reddit(username=reddit_app_username, password=reddit_app_password, app_id=reddit_client_id, app_secret=reddit_app_secret, subreddit=subreddit, pimg_id=imgur_client_id, pimg_secret=imgur_app_secret) self._checker = DbConnection() colorinit(convert=False)
def init(): # We add a StreamHandler and formatter to the root logger, and init colorama. colorinit(convert=True) handler = logging.StreamHandler(sys.stdout) handler.setFormatter(ImpacketFormatter()) logging.getLogger().addHandler(handler) logging.getLogger().setLevel(logging.INFO)
def __init__(self, game: Game, use_color=True): """Init.""" colorinit(convert=True) self.use_color = use_color self.game = game self.maze = game.maze self.hero = game.hero self.turns = 0
def main(): colorinit() try: target_dir = sys.argv[1] except IndexError: print_usage() else: if not os.path.isdir(target_dir): print_usage() else: ## ------ filter the repeated ---------------------- hashes = {} # the repeated repeated = {} # count for all file no matter repeated or not file_count = 0 for root, dirs, files in os.walk(target_dir): if root == target_dir: for file in files: # print(file) # print(os.path.join(root, file)) m = hashlib.md5() with open(os.path.join(root, file), 'rb') as f: while True: buff = f.read(2048) if not buff: break m.update(buff) # returned md5 is of string format md5 = m.hexdigest() ## ---------------print item process----------------- file_count += 1 filesize = round( os.path.getsize(os.path.join(root, file)) / (1024 * 1024), 2) print( str(file_count) + ":\t", file + "\t" + str(filesize) + "M" + "\t" + md5) try: first = hashes[md5] except KeyError: hashes[md5] = file else: try: existed = repeated[md5] except KeyError: repeated[md5] = [first, file] else: repeated[md5].append(file) ## ------ print the repeated ---------------------- for key, value in repeated.items(): print("File(s)\t{}\tis repeated with md5\t{}\t!".format( colored(value, 'green'), colored(key, 'red')))
def __init__(self, root, check=False, verbose=False): u""" """ self.root = root colorinit(autoreset=True) self.collection = {} self.load() if verbose: self.printVerbose()
def main(): """the main function""" parser = argparse.ArgumentParser( description='SA Report Checker', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument( '--version', action='version', version='%(prog)s {version}'.format(version=__version__)) parser.add_argument("report", help="the report to check") parser.add_argument("-v", "--verbose", help="enable verbose output", action="store_true") parser.add_argument("-c", "--checks", help="checks to run against report\n" "ALL = all checks (default)\n" "o = common oversights\n" "r = caption references\n" "a = acronyms\n", default="ALL") args = parser.parse_args() # set variables from CLI args report = docx.Document(args.report) verbose = args.verbose checks = args.checks # set colorama to automatically reset after each print colorinit(autoreset=True) print_header() if checks == "ALL": find_common_oversights(report, verbose) find_references(report, verbose) find_acronyms(report, verbose) else: if "o" in checks: find_common_oversights(report, verbose) if "r" in checks: find_references(report, verbose) if "a" in checks: find_acronyms(report, verbose)
# coding: utf-8 from __future__ import print_function, unicode_literals import sys import platform import os from six import PY2, string_types if sys.stdout.isatty(): # You're running in a real terminal try: from colorama import init as colorinit, Fore, Style colorinit(autoreset=True) is_terminal = True except ImportError: is_terminal = False else: # You're being piped or redirected is_terminal = False #is_terminal = False def make_log(display=False): """ Creates 'pyNastran.log' file with information about working environment, such as Python version, platform, architecture, etc. Useful for debugging. Parameters ---------- display : bool do not only create file but also print log information """
import json from sys import argv, exit from colorama import init as colorinit from colorama import Fore, Style colorinit() data = [] words = [] # data = open('dictionary.json', 'r', encoding = 'utf-8').read() # data = json.loads(data) # words = data.keys() def loadAlphabetDict(alphabet = 'a'): global data global words data = open('json_files/gcide_' + alphabet + '.json', 'r', encoding = 'utf-8').read() data = json.loads(data) words = data.keys() # idea # one by one - left to right - double chars - skip def run(): if len(argv) == 1: print('Enter word > ', end='') word = input() print() else: word = argv[1] word = word.lower()
import json from sys import argv, exit from colorama import init as colorinit from colorama import Fore, Style colorinit() data = [] words = [] # data = open('dictionary.json', 'r', encoding = 'utf-8').read() # data = json.loads(data) # words = data.keys() def loadAlphabetDict(alphabet='a'): global data global words data = open('json_files/gcide_' + alphabet + '.json', 'r', encoding='utf-8').read() data = json.loads(data) words = data.keys() # idea # one by one - left to right - double chars - skip def run(): if len(argv) == 1: print('Enter word > ', end='')
# coding: utf-8 from __future__ import print_function, unicode_literals import sys import platform import os from six import PY2, string_types IS_TERMINAL = False if hasattr(sys.stdout, 'isatty'): # pyInstaller <= 3.1 doesn't have this IS_TERMINAL = sys.stdout.isatty() # You're running in a real terminal try: from colorama import init as colorinit, Fore # type: ignore colorinit(autoreset=True) IS_COLORAMA = True except ImportError: IS_COLORAMA = False USE_COLORAMA = IS_COLORAMA and IS_TERMINAL #else: #from colorama import init as colorinit, Fore #colorinit(autoreset=True) ## You're being piped or redirected #IS_TERMINAL = False #IS_TERMINAL = False def make_log(display=False):
def initColorama(cls): colorinit(autoreset=True)
def __init__(self): colorinit()
def __init__(self): # print("%s init"%(self.__class__.__name__)) self.__version = "0.1" self.__string = "" colorinit(autoreset=True)