Python codecs.ascii_encode() Examples

The following are 30 code examples of codecs.ascii_encode(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module codecs , or try the search function .
Example #1
Source File: manual.py    From stem with GNU Lesser General Public License v3.0 6 votes vote down vote up
def test_escapes_non_ascii(self):
    """
    Check that our manual parser escapes all non-ascii characters. If this
    fails then that means someone probably added a new type of non-ascii
    character. Easy to fix: please simply add an escape for it in
    stem/manual.py's _get_categories().
    """

    self.requires_downloaded_manual()

    def check(content):
      try:
        codecs.ascii_encode(content, 'strict')
      except UnicodeEncodeError as exc:
        self.fail("Unable to read '%s' as ascii: %s" % (content, exc))

    categories = stem.manual._get_categories(self.man_content)

    for category, lines in categories.items():
      check(category)

      for line in lines:
        check(line) 
Example #2
Source File: ascii.py    From ImageFusion with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #3
Source File: ascii.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #4
Source File: ascii.py    From ImageFusion with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #5
Source File: ascii.py    From python2017 with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #6
Source File: ascii.py    From datafari with Apache License 2.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #7
Source File: ascii.py    From Splunking-Crime with GNU Affero General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #8
Source File: ascii.py    From PhonePi_SampleServer with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #9
Source File: ascii.py    From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #10
Source File: ascii.py    From medicare-demo with Apache License 2.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #11
Source File: ascii.py    From syntheticmass with Apache License 2.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #12
Source File: ascii.py    From odoo13-x64 with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #13
Source File: ascii.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #14
Source File: ascii.py    From CTFCrackTools-V2 with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #15
Source File: ascii.py    From RevitBatchProcessor with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #16
Source File: ascii.py    From Carnets with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #17
Source File: ascii.py    From PokemonGo-DesktopMap with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #18
Source File: ascii.py    From unity-python with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #19
Source File: ascii.py    From android_universal with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #20
Source File: ascii.py    From canape with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #21
Source File: ascii.py    From CTFCrackTools with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #22
Source File: ascii.py    From multicast-relay with GNU General Public License v3.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #23
Source File: ascii.py    From Safejumper-for-Desktop with GNU General Public License v2.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #24
Source File: ascii.py    From meddle with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #25
Source File: ascii.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #26
Source File: test_codecs.py    From ironpython2 with Apache License 2.0 5 votes vote down vote up
def test_ascii_encode(self):
        #sanity
        new_str, size = codecs.ascii_encode("abc")
        self.assertEqual(new_str, 'abc')
        self.assertEqual(size, 3) 
Example #27
Source File: ascii.py    From kobo-predict with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #28
Source File: ascii.py    From BinderFilter with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #29
Source File: ascii.py    From Computable with MIT License 5 votes vote down vote up
def encode(self, input, final=False):
        return codecs.ascii_encode(input, self.errors)[0] 
Example #30
Source File: tag.py    From eyeD3 with GNU General Public License v3.0 5 votes vote down vote up
def setTextFrame(self, fid: bytes, txt: str):
        fid = b(fid, ascii_encode)
        if not fid.startswith(b"T") or fid.startswith(b"TX"):
            raise ValueError("Invalid frame-id for text frame")

        if not txt and self.frame_set[fid]:
            del self.frame_set[fid]
        elif txt:
            self.frame_set.setTextFrame(fid, txt)

    # FIXME: is returning data not a Frame.