def check_unicode_docstring(docstring, context, is_script): r"""Use u\"\"\" for Unicode docstrings. For Unicode docstrings, use u\"\"\"Unicode triple-quoted stringsr\"\"\". """ if (docstring and not all(isascii(char) for char in docstring) and not docstring.startswith('u"""')): return True
def check_unicode_docstring(docstring, context, is_script): '''PEP257 Use u""" for Unicode docstrings. For Unicode docstrings, use u"""Unicode triple-quoted strings""". ''' if (docstring and not all(isascii(char) for char in docstring) and not docstring.startswith('u"""')): return 'PEP257 Use u""" for Unicode docstrings.',
def on_key(self, ch) -> bool: if self is self.container.focus: cmd = self.cmd.get(ch) if cmd is not None: cmd() self._cursor_refresh() return True elif isinstance(ch, str): if _ascii.isascii(ch): if _ascii.isprint(ch): self.add_char(ch) self._cursor_refresh() return True else: self.add_char(ch) self._cursor_refresh() return True return False
def clean_xml_string(input_string): '''removes invalid characters from an XML string''' from curses import ascii return ''.join(c for c in input_string if ascii.isascii(c))
def is_ascii(s): return all(isascii(c) for c in s)
errorfile = False for letrasfile in nomfile: if dospaces == True: if letrasfile == " ": filecorrect = filecorrect.replace(" ", "_") errorfile = True if enforceillegal == True: for i in illegalchars: if letrasfile == i: filecorrect = filecorrect.replace(i, "Z") errorfile = True if not isascii(letrasfile): errorfile = True for (chara, charb) in responsechar: if letrasfile == chara: filecorrect == filecorrect.replace(chara, charb) filecorrect = filecorrect.replace(letrasfile, "X") if dodebug == True: msg = "Illegal character (" + letrasfile + ")" print errmensaje % (msg, nomfile, root, filecorrect) if len(nomfile) >= 64 and trim64 == True: filecorrect = filecorrect[0:50] + "__" + filecorrect[-11:] errorfile = True
except FileNotFoundError: print('The directory path is not valid.') exit() else: print('Working directory changed to: ', os.getcwd(), '\n') dir_contents = os.listdir() changed_count = 0 unchanged_count = 0 for item in dir_contents: new_name = '' hasChanged = False for letter in item: try: if not ascii.isascii(letter): new_name += str(digit(letter)) hasChanged = True else: new_name += letter except ValueError: new_name += str(letter) if hasChanged: try: os.rename(item, new_name) except: print('<ERROR> Failed to rename ', item) pass else: print(item + ' --> ' + new_name)
def isascii(self,s): return all(ascii.isascii(c) for c in s)
def clear_unascii(s): return ''.join([c for c in s if ascii.isascii(c)])