def showFolderItems(self, p): a = os.listdir(p) a.sort() for tmp in a: item = os.path.join(p, tmp) if os.path.isdir(item): if tmp[0] == '.': pass else: if self.win.is_git_dir: state_dict = gitcmds.specified_worktree_state_dict(head='HEAD', p=item[len(self.gitRepo.git.worktree()) + 1:]) is_clean = True for v in state_dict.values(): if v: is_clean = False break if is_clean: self.listInsertOneItem(item, self.fldridx) else: self.listInsertOneItem(item, self.fldropenidx) else: self.listInsertOneItem(item, self.fldridx) for tmp in a: item = os.path.join(p, tmp) if os.path.isfile(item): if tmp[0] == '.': pass else: if self.win.is_git_dir: #self.gitRepo.update_status() gitItem = item[len(self.gitRepo.git.worktree()) + 1:] if core.encode(gitItem) in self.gitRepo.untracked: self.listInsertOneItem(item, self.untrackedidx) elif core.encode(gitItem) in self.gitRepo.modified: self.listInsertOneItem(item, self.modifiedidx) elif core.encode(gitItem) in self.gitRepo.staged: self.listInsertOneItem(item, self.stagedidx) elif core.encode(gitItem) in self.gitRepo.unmerged: self.listInsertOneItem(item, self.unmergedidx) else: self.listInsertOneItem(item, self.commitedidx) else: self.listInsertOneItem(item, self.fileidx)
def stage_paths(self, paths): """Stages add/removals to git.""" if not paths: self.stage_all() return add = [] remove = [] for path in set(paths): if os.path.exists(core.encode(path)): add.append(path) else: remove.append(path) self.notify_observers(self.message_about_to_update) # `git add -u` doesn't work on untracked files if add: self._sliced_add(add) # If a path doesn't exist then that means it should be removed # from the index. We use `git add -u` for that. if remove: while remove: self.git.add('--', u=True, with_stderr=True, *remove[:42]) remove = remove[42:] self._update_files() self.notify_observers(self.message_updated)
def cdisp(argv): try: opts, args = getopt.getopt(argv, "c:s:v", ["compress="]) if len(opts) == 0: print(help_msg) except getopt.GetoptError: print(help_msg) sys.exit(2) for opt, arg in opts: if opt == '-h': print(help_msg) sys.exit() img = core.decode(img_path, color_mode, mode) elif opt in ("-c", "--compress"): img_path = arg color_mode = args[0] if len(args) > 0 else "F" mode = args[1] if len(args) > 1 else "D2" threshold_1 = float(args[2]) if len(args) > 2 else 0.05 threshold_2 = float(args[3]) if len(args) > 3 else threshold_1 threshold_3 = float(args[4]) if len(args) > 4 else threshold_1 encoded_img = core.encode(img_path, color_mode, mode, [threshold_1,threshold_2, threshold_3]) img = core.decode(encoded_img,color_mode,mode) elif opt in ("-s", "--save"): #save as image core.save(img, arg) elif opt == "-v": #verbose core.verbose = True print("Verbose: " + str(core.verbose))
def inline(bot, update): query = update.inline_query.query if not query: return results = list() results.append( InlineQueryResultArticle(id='brainfuck', title='Brainfuckify', description='Brainfuck encoded text', input_message_content=InputTextMessageContent( encode(query)))) translate_success, translation, translate_iter = simulate(query) translation = ''.join( map(lambda x: '�' if x not in string.printable else x, translation)) translation = 'Result: ' + translation results.append( InlineQueryResultArticle(id='translated', title='Decode', description='Brainfuck decoded text', input_message_content=InputTextMessageContent( escape_markdown(translation)))) bot.answer_inline_query(update.inline_query.id, results)
def __init__(self): Command.__init__(self) untracked = self.model.untracked suffix = len(untracked) > 1 and 's' or '' io = StringIO() io.write('# %s untracked file%s\n' % (len(untracked), suffix)) if untracked: io.write('# possible .gitignore rule%s:\n' % suffix) for u in untracked: io.write('/'+core.encode(u)) self.new_diff_text = core.decode(io.getvalue()) self.new_mode = self.model.mode_untracked
def __init__(self, name, revision, sign=False, message=''): Command.__init__(self) self._name = name self._message = core.encode(message) self._revision = revision self._sign = sign
def __init__(self, amend, msg): ResetMode.__init__(self) self.amend = amend self.msg = core.encode(msg) self.old_commitmsg = self.model.commitmsg self.new_commitmsg = ''
def message(bot, update): bot.send_message(chat_id=update.message.chat_id, text=encode(update.message.text))
checkVersion() print(header1) print(mainOption) try: while True: choice = input("") if choice.lower() == 'c': clear() print(header1) print(mainOption) elif choice.lower() == "e" or choice.lower() == "exit": sys.exit(Fore.RED + "\nHave a good day ! :)") print(Style.RESET_ALL) elif choice.lower() == '1': clear() encode() print(header1) print(mainOption) elif choice.lower() == '2': clear() decode() print(header1) print(mainOption) except KeyboardInterrupt: sys.exit(Fore.RED + "\nHave a good day ! :)") print(Style.RESET_ALL)
def fork(args): """Launch a command in the background.""" encoded_args = [core.encode(arg) for arg in args] return subprocess.Popen(encoded_args).pid
def shell_split(s): """Split string apart into utf-8 encoded words using shell syntax""" try: return shlex.split(core.encode(s)) except ValueError: return [s]
def write(path, contents): """Writes a raw string to a file.""" fh = open(core.encode(path), 'wb') core.write(fh, core.encode(contents)) fh.close()
def slurp(path): """Slurps a filepath into a string.""" fh = open(core.encode(path)) slushy = core.read(fh) fh.close() return core.decode(slushy)