Use MyCapitains program to convert TEI to plaintext.
557091
def onekgreek_tei_xml_to_text_capitains():
    """"""
    file = os.path.expanduser(
        '~/cltk_data/greek/text/greek_text_first1kgreek/data/tlg0627/tlg021/tlg0627.tlg021.1st1K-grc1.xml')
    xml_dir = os.path.expanduser('~/cltk_data/greek/text/greek_text_first1kgreek/data/*/*/*.xml')
    xml_paths = glob.glob(xml_dir)
    if not len(xml_paths):
        logger.error('1K Greek corpus not installed. Use CorpusInstaller to get `First1KGreek`.')
        raise FileNotFoundError
    xml_paths = [path for path in xml_paths if '__cts__' not in path]

    # new dir
    new_dir = os.path.expanduser('~/cltk_data/greek/text/greek_text_first1kgreek_plaintext/')
    if not os.path.isdir(new_dir):
        os.makedirs(new_dir)

    for xml_path in xml_paths:
        _, xml_name = os.path.split(xml_path)
        xml_name = xml_name.rstrip('.xml')
        xml_name += '.txt'

        plain_text = ''
        with open(xml_path) as file_open:
            text = CapitainsCtsText(resource=file_open)
            for ref in text.getReffs(level=len(text.citation)):
                psg = text.getTextualNode(subreference=ref, simple=True)
                text_line = psg.export(Mimetypes.PLAINTEXT, exclude=["tei:note"])
                plain_text += text_line

        new_plaintext_path = os.path.join(new_dir, xml_name)
        with open(new_plaintext_path, 'w') as file_open:
            file_open.write(plain_text)
983488
def encrypt(plaintext_str, keys):
    
    assert keys, 'Must provide at least one key to encrypt with'
    ctx = gpg.core.Context(armor=True)
    out = ctx.encrypt(plaintext_str, recipients=keys, sign=False,
                      always_trust=True)[0]
    return out
818994
def dump(self):
        '''
        
        '''
        return self.priv.private_bytes(
            encoding=c_ser.Encoding.DER,
            format=c_ser.PrivateFormat.PKCS8,
            encryption_algorithm=c_ser.NoEncryption())
708562
def encrypt(self, plain, algorithm='md5'):
        
        plain = helper.to_bytes(plain)
        return getattr(hashlib, algorithm)(plain).hexdigest()
410880
def to_native(self, obj):
        """"""
        ret = super(UserSerializer, self).to_native(obj)
        del ret['password']
        return ret
900952
def authenticationReject():
    """"""
    a = TpPd(pd=0x5)
    b = MessageType(mesType=0x11)  # 00010001
    packet = a / b
    return packet
229129
def unserialize(cls, string, secret_key):
        
        if isinstance(string, text_type):
            string = string.encode('utf-8', 'replace')
        if isinstance(secret_key, text_type):
            secret_key = secret_key.encode('utf-8', 'replace')
        try:
            base64_hash, data = string.split(b'?', 1)
        except (ValueError, IndexError):
            items = ()
        else:
            items = {}
            mac = hmac(secret_key, None, cls.hash_method)
            for item in data.split(b'&'):
                mac.update(b'|' + item)
                if not b'=' in item:
                    items = None
                    break
                key, value = item.split(b'=', 1)
                # try to make the key a string
                key = url_unquote_plus(key.decode('ascii'))
                try:
                    key = to_native(key)
                except UnicodeError:
                    pass
                items[key] = value

            # no parsing error and the mac looks okay, we can now
            # sercurely unpickle our cookie.
            try:
                client_hash = base64.b64decode(base64_hash)
            except TypeError:
                items = client_hash = None
            if items is not None and safe_str_cmp(client_hash, mac.digest()):
                try:
                    for key, value in iteritems(items):
                        items[key] = cls.unquote(value)
                except UnquoteError:
                    items = ()
                else:
                    if '_expires' in items:
                        if time() > items['_expires']:
                            items = ()
                        else:
                            del items['_expires']
            else:
                items = ()
        return cls(items, secret_key, False)
13694
def make_ccys(db):
    '''
    
    '''
    dfr = 4
    dollar = r'\u0024'
    peso = r'\u20b1'
    kr = r'kr'
    insert = db.insert

    # G10 & SCANDI
    insert('EUR', '978', 'EU', 1,
           'Euro', dfr, 'EU', '30/360', 'ACT/360',
           future='FE', symbol=r'\u20ac', html='&#x20ac;')
    insert('GBP', '826', 'BP', 2,
           'British Pound', dfr, 'GB', 'ACT/365', 'ACT/365',
           symbol=r'\u00a3', html='&#xa3;')
    insert('AUD', '036', 'AD', 3,
           'Australian Dollar', dfr, 'AU', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('NZD', '554', 'ND', 4,
           'New-Zealand Dollar', dfr, 'NZ', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('USD', '840', 'UD', 5,
           'US Dollar', 0, 'US', '30/360', 'ACT/360',
           future='ED', symbol=dollar, html='&#x24;')
    insert('CAD', '124', 'CD', 6,
           'Canadian Dollar', dfr, 'CA', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('CHF', '756', 'SF', 7,
           'Swiss Franc', dfr, 'CH', '30/360', 'ACT/360',
           symbol=r'Fr', html='&#x20a3;')
    insert('NOK', '578', 'NK', 8,
           'Norwegian Krona', dfr, 'NO', '30/360', 'ACT/360',
           symbol=kr, html=kr)
    insert('SEK', '752', 'SK', 9,
           'Swedish Krona', dfr, 'SE', '30/360', 'ACT/360',
           symbol=kr, html=kr)
    insert('DKK', '208', 'DK', 10,
           'Danish Krona', dfr, 'DK', '30/360', 'ACT/360',
           symbol=kr, html=kr)
    insert('JPY', '392', 'JY', 10000,
           'Japanese Yen', 2,  'JP', 'ACT/365', 'ACT/360',
           symbol=r'\u00a5', html='&#xa5;')

    # ASIA
    insert('CNY', '156', 'CY', 680,
           'Chinese Renminbi', dfr, 'CN', 'ACT/365', 'ACT/365',
           symbol=r'\u00a5', html='&#xa5;')
    insert('KRW', '410', 'KW', 110000,
           'South Korean won', 2, 'KR', 'ACT/365', 'ACT/365',
           symbol=r'\u20a9', html='&#x20a9;')
    insert('SGD', '702', 'SD', 15,
           'Singapore Dollar', dfr, 'SG', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('IDR', '360', 'IH', 970000,
           'Indonesian Rupiah', 0, 'ID', 'ACT/360', 'ACT/360',
           symbol=r'Rp', html='Rp')
    insert('THB', '764', 'TB', 3300,
           'Thai Baht', 2, 'TH', 'ACT/365', 'ACT/365',
           symbol=r'\u0e3f', html='&#xe3f;')
    insert('TWD', '901', 'TD', 18,
           'Taiwan Dollar', dfr, 'TW', 'ACT/365', 'ACT/365',
           symbol=dollar, html='&#x24;')
    insert('HKD', '344', 'HD', 19,
           'Hong Kong Dollar', dfr, 'HK', 'ACT/365', 'ACT/365',
           symbol=r'\u5713', html='HK&#x24;')
    insert('PHP', '608', 'PP', 4770,
           'Philippines Peso', dfr, 'PH', 'ACT/360', 'ACT/360',
           symbol=peso, html='&#x20b1;')
    insert('INR', '356', 'IR', 4500,
           'Indian Rupee', dfr, 'IN', 'ACT/365', 'ACT/365',
           symbol=r'\u20a8', html='&#x20a8;')
    insert('MYR', '458', 'MR', 345,
           'Malaysian Ringgit', dfr, 'MY', 'ACT/365', 'ACT/365')
    insert('VND', '704', 'VD', 1700000,
           'Vietnamese Dong', 0,  'VN', 'ACT/365', 'ACT/365',
           symbol=r'\u20ab', html='&#x20ab;')

    # LATIN AMERICA
    insert('BRL', '986', 'BC', 200,
           'Brazilian Real', dfr, 'BR', 'BUS/252', 'BUS/252',
           symbol=r'R$')
    insert('PEN', '604', 'PS', 220,
           'Peruvian New Sol', dfr, 'PE', 'ACT/360', 'ACT/360',
           symbol=r'S/.')
    insert('ARS', '032', 'AP', 301,
           'Argentine Peso', dfr, 'AR', '30/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    insert('MXN', '484', 'MP', 1330,
           'Mexican Peso', dfr, 'MX', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    insert('CLP', '152', 'CH', 54500,
           'Chilean Peso', 2,  'CL', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    insert('COP', '170', 'CL', 190000,
           'Colombian Peso', 2,  'CO', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    # TODO: Check towletters code and position
    insert('JMD', '388', 'JD', 410,
           'Jamaican Dollar', dfr, 'JM', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    # TODO: Check towletters code and position
    insert('TTD', '780', 'TT', 410,
           'Trinidad and Tobago Dollar', dfr, 'TT', 'ACT/360', 'ACT/360',
           symbol=dollar, html='&#x24;')
    # TODO: Check towletters code and position
    insert('BMD', '060', 'BD', 410,
           'Bermudian Dollar', dfr, 'BM',
           symbol=dollar, html='&#x24;')

    # EASTERN EUROPE
    insert('CZK', '203', 'CK', 28,
           'Czech Koruna', dfr, 'CZ', 'ACT/360', 'ACT/360',
           symbol=r'\u004b\u010d')
    insert('PLN', '985', 'PZ', 29,
           'Polish Zloty', dfr, 'PL', 'ACT/ACT', 'ACT/365',
           symbol=r'\u0050\u0142')
    insert('TRY', '949', 'TY', 30,
           'Turkish Lira', dfr, 'TR', 'ACT/360', 'ACT/360',
           symbol=r'\u0054\u004c')
    insert('HUF', '348', 'HF', 32,
           'Hungarian Forint', dfr, 'HU', 'ACT/365', 'ACT/360',
           symbol=r'Ft', html='Ft')
    insert('RON', '946', 'RN', 34,
           'Romanian Leu', dfr, 'RO', 'ACT/360', 'ACT/360')
    insert('RUB', '643', 'RR', 36,
           'Russian Ruble', dfr, 'RU', 'ACT/ACT', 'ACT/ACT',
           symbol=r'\u0440\u0443\u0431')
    # TODO: Check towletters code and position
    insert('HRK', '191', 'HK', 410,
           'Croatian kuna', dfr, 'HR',
           symbol=r'kn')
    # TODO: Check towletters code and position
    insert('KZT', '398', 'KT', 410,
           'Tenge',  dfr, 'KZ',
           symbol=r'\u20b8', html='&#x20b8;')
    # TODO: Check towletters code and position
    insert('BGN', '975', 'BN', 410,
           'Bulgarian Lev', dfr, 'BG',
           symbol=r'\u043b\u0432.', html='&#1083;&#1074;')

    # MIDDLE EAST & AFRICA
    insert('ILS', '376', 'IS', 410,
           'Israeli Shekel', dfr, 'IL', 'ACT/365', 'ACT/365',
           symbol=r'\u20aa', html='&#x20aa;')
    # TODO: Check towletters code and position
    insert('AED', '784', 'AE', 410,
           'United Arab Emirates Dirham', dfr, 'AE')
    # TODO: Check towletters code and position
    insert('QAR', '634', 'QA', 410,
           'Qatari Riyal', dfr, 'QA',
           symbol=r'\ufdfc', html='&#xfdfc;')
    # TODO: Check towletters code and position
    insert('SAR', '682', 'SR', 410,
           'Saudi Riyal', dfr, 'SA',
           symbol=r'\ufdfc', html='&#xfdfc;')
    insert('EGP', '818', 'EP', 550,
           'Egyptian Pound', dfr, 'EG',
           symbol=r'\u00a3', html='&#xa3;')
    insert('ZAR', '710', 'SA', 750,
           'South African Rand', dfr, 'ZA', 'ACT/365', 'ACT/365',
           symbol=r'R', html='R')

    # BITCOIN
    insert('XBT', '000', 'BT', -1,
           'Bitcoin', 8, 'WW',
           symbol=r'\u0e3f', html='&#xe3f;')
854912
def encap(self, pkt):
        """"""
        if pkt.name != Ether().name:
            raise TypeError('cannot encapsulate packet in MACsec, must be Ethernet')  # noqa: E501
        hdr = copy.deepcopy(pkt)
        payload = hdr.payload
        del hdr.payload
        tag = MACsec(sci=self.sci, an=self.an,
                     SC=self.send_sci,
                     E=self.e_bit(), C=self.c_bit(),
                     shortlen=MACsecSA.shortlen(pkt),
                     pn=(self.pn & 0xFFFFFFFF), type=pkt.type)
        hdr.type = ETH_P_MACSEC
        return hdr / tag / payload
79231
def to_python(self, value):
        """"""
        if value in self.empty_values:
            return ""
        value = force_text(value).strip()
        return value
471177
def from_text(textring):
    """"""

    keyring = {}
    for keytext in textring:
        keyname = dns.name.from_text(keytext)
        secret = base64.decodestring(textring[keytext])
        keyring[keyname] = secret
    return keyring
485382
def _der_to_raw(self, der_signature):
        """"""
        r, s = decode_dss_signature(der_signature)
        component_length = self._sig_component_length()
        return int_to_bytes(r, component_length) + int_to_bytes(s, component_length)
700987
def encode(raw):
    """"""
    return raw \
        .replace(bytes([SLIP_ESC]), bytes([SLIP_ESC, SLIP_ESC_ESC])) \
        .replace(bytes([SLIP_END]), bytes([SLIP_ESC, SLIP_ESC_END]))
192865
def plaintext(method, options = {})
      bootstrap = form_bootstrap.scoped(options.delete(:bootstrap))
      draw_form_group(bootstrap, method, options) do
        remove_css_class!(options, "form-control")
        add_css_class!(options, "form-control-plaintext")
        options[:readonly] = true
        ActionView::Helpers::FormBuilder.instance_method(:text_field).bind(self).call(method, options)
      end
    end
1068861
private void encodeThis() throws IOException {
        if (certPolicies == null || certPolicies.isEmpty()) {
            this.extensionValue = null;
        } else {
            DerOutputStream os = new DerOutputStream();
            DerOutputStream tmp = new DerOutputStream();

            for (PolicyInformation info : certPolicies) {
                info.encode(tmp);
            }

            os.write(DerValue.tag_Sequence, tmp);
            this.extensionValue = os.toByteArray();
        }
    }
149490
def convertToMapPic(byteString, mapWidth):
    """"""
    data = []
    line = ""
    for idx,char in enumerate(byteString):
        line += str(ord(char))
        if ((idx+1)%mapWidth)==0:
            data.append(line)
            line = ""
    return data
1193994
def make_str(value):
    """"""
    if isinstance(value, bytes):
        try:
            return value.decode(get_filesystem_encoding())
        except UnicodeError:
            return value.decode('utf-8', 'replace')
    return text_type(value)