Beispiel #1
0
def choose_menu():
	r=input(k+"\n["+p+"•"+k+"]"+p+" Choose : ")
	if r=="":
		print((k+"["+p+"!"+k+"]"+p+" Fill In The Correct"))
		menu()
	elif r=="1":
		exit(public.public())
	elif r=="2":
		exit(follow.follow())
	elif r=="3":
		exit(likers.likers())
	elif r=="4":
		search_name()
	elif r=="5":
		exit(crack.pilihcrack())
	elif r=="6":
		target()
	elif r=="7":
		exit(random_numbers.random_numbers())
	elif r=="8":
		exit(random_email.random_email())
	elif r=="9":
		ress()
	elif r=="0":
		try:
			jalan(k+"\n["+p+"•"+k+"]"+p+" Thanks For Using My Script")
			os.system("rm -rf login.txt")
			exit()
		except Exception as e:
			print((k+"["+p+"!"+k+"]"+p+" Error %s"%e))
	else:
		print((k+"["+p+"!"+k+"]"+p+" Wrong Input"))
		menu()	
    def update_b_goodsSKULocation(self, goodsSKUIDs):
        print "Begin:{},Time:{},Count:{}".format("b_goodsSKULocation", datetime.now(), len(goodsSKUIDs))
        goodsSKUIDs = list(set(goodsSKUIDs))
        objs, LocationIDs = self.getPyInfo(goodsSKUIDs)
        try:
            insertSQL = "Replace INTO py_db.B_GoodsSKULocation (NID,StoreID,LocationID,GoodsSKUID) VALUES (%s,%s,%s,%s)"
            public_obj = public(self.db_conn, self.sqlserver_conn)
            public_obj.commitmanyFun(objs, insertSQL)
            print "End:{},Time:{},Count:{}".format("b_goodsSKULocation", datetime.now(), len(goodsSKUIDs))

            # 更新b_storelocation表
            b_storelocation_obj = b_storelocation(self.db_conn, self.sqlserver_conn)
            b_storelocation_obj.update_b_storelocation(LocationIDs)
        except MySQLdb.Error, e:
            print "Mysql Error %d: %s" % (e.args[0], e.args[1])
 def update_b_supplier(self, SupplierIDs):
     print "Begin{},Time:{},Count:{}".format("b_supplier", datetime.now(),
                                             len(SupplierIDs))
     objs = self.getPyInfo(SupplierIDs)
     try:
         insertSQL = "replace INTO py_db.b_supplier(NID,CategoryID,SupplierCode,SupplierName,FitCode,LinkMan,Address,OfficePhone," \
                     "Mobile,Used,Recorder,InputDate,Modifier,ModifyDate,Email,QQ,MSN,ArrivalDays,URL,Memo," \
                     "Account,CreateDate,SupPurchaser,supplierLoginId" \
                     ") VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s," \
                     "%s,%s,%s,%s,%s,%s)"
         public_obj = public(self.db_conn, self.sqlserver_conn)
         public_obj.commitmanyFun(objs, insertSQL)
         print "End{},Time:{},Count:{}".format("b_supplier", datetime.now(),
                                               len(SupplierIDs))
     except MySQLdb.Error, e:
         print "Mysql Error %d: %s" % (e.args[0], e.args[1])
 def update_b_storelocation(self, LocationIDs):
     print "Begin:{},Time:{},Count:{}".format("b_storelocation",
                                              datetime.now(),
                                              len(LocationIDs))
     LocationIDs = list(set(LocationIDs))  # 给列表去重
     objs = self.getPyInfo(LocationIDs)
     try:
         insertSQL = "REPLACE INTO py_db.B_StoreLocation (NID,StoreID,StoreCode,LocationName,LocationOrder,Address,Used,Memo,Recorder," \
                     "InputDate,Modifier,ModifyDate) VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
         public_obj = public(self.db_conn, self.sqlserver_conn)
         public_obj.commitmanyFun(objs, insertSQL)
         print "End:{},Time:{},Count:{}".format("b_storelocation",
                                                datetime.now(),
                                                len(LocationIDs))
     except MySQLdb.Error, e:
         print "Mysql Error %d: %s" % (e.args[0], e.args[1])
    def update_b_goodsSKU(self, SKUList):
        print "Begin:{},Time:{},Count:{}".format("b_goodsSKU", datetime.now(),
                                                 len(SKUList))
        SKUList = list(set(SKUList))
        cursor = self.db_conn.cursor()
        objs, goodsSKUIDs = self.getPyInfo(SKUList)
        try:
            insertSQL = "REPLACE INTO py_db.b_goodssku(NID,GoodsID,SKU,property1,property2,property3,SKUName,LocationID," \
                        "BmpFileName,SellCount,Remark,SellCount1,SellCount2,SellCount3,Weight,CostPrice,RetailPrice," \
                        "MaxNum,MinNum,GoodsSKUStatus,ChangeStatusTime,ASINN,UPC,ModelNum,ChangeCostTime,linkurl" \
                        ") VALUES (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s," \
                        "%s,%s,%s,%s,%s,%s,%s,%s)"
            public_obj = public(self.db_conn, self.sqlserver_conn)
            public_obj.commitmanyFun(objs, insertSQL)
            print "End:{},Time:{},Count:{}".format("b_goodsSKU",
                                                   datetime.now(),
                                                   len(SKUList))

            # 更新B_GoodsSKULocation 表
            b_goodsSKULocation_obj = b_goodsSKULocation(
                self.db_conn, self.sqlserver_conn)
            b_goodsSKULocation_obj.update_b_goodsSKULocation(goodsSKUIDs)
        except MySQLdb.Error, e:
            print "Mysql Error %d: %s" % (e.args[0], e.args[1])
Beispiel #6
0
        'list:admin:action:unsubscribe',
        'list:admin:notice:subscribe',
        'list:admin:notice:unrecognized',
        'list:admin:notice:unsubscribe',
        'list:member:digest:footer',
        'list:member:digest:header',
        'list:member:digest:masthead',
        'list:member:regular:footer',
        'list:member:regular:header',
        'list:user:action:subscribe',
        'list:user:action:unsubscribe',
        'list:user:notice:goodbye',
        'list:user:notice:hold',
        'list:user:notice:no-more-today',
        'list:user:notice:post',
        'list:user:notice:probe',
        'list:user:notice:refuse',
        'list:user:notice:rejected',
        'list:user:notice:welcome',
    }
}

# These have alternate names.
ALT_TEMPLATE_NAMES = {
    'list:member:digest:footer': 'list:member:generic:footer.txt',
    'list:member:regular:footer': 'list:member:generic:footer.txt',
}

public(ALL_TEMPLATES=ALL_TEMPLATES)
public(ALT_TEMPLATE_NAMES=ALT_TEMPLATE_NAMES)
Beispiel #7
0
        'list:admin:notice:unsubscribe',
        'list:member:digest:masthead',
        'list:user:action:subscribe',
        'list:user:action:unsubscribe',
        'list:user:notice:hold',
        'list:user:notice:no-more-today',
        'list:user:notice:post',
        'list:user:notice:probe',
        'list:user:notice:refuse',
        'list:user:notice:welcome',
    }
}

# These have other names.
ALL_TEMPLATES.update({
    'list:member:digest:footer':
    'list:member:generic:footer.txt',
    'list:member:regular:footer':
    'list:member:generic:footer.txt',
})

# These are some extra supported templates which don't have a mapping to a
# file in the source tree.
ALL_TEMPLATES.update({
    'list:member:digest:header': None,
    'list:member:regular:header': None,
    'list:user:notice:goodbye': None,
})

public(ALL_TEMPLATES=ALL_TEMPLATES)
Beispiel #8
0
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
"""Autoresponder."""

from datetime import timedelta
from enum import Enum
from public import public
from zope.interface import Attribute, Interface

public(ALWAYS_REPLY=timedelta())


@public
class Response(Enum):
    # Your message was held for approval.
    hold = 1
    # Email commands, i.e. -request messages.
    command = 2
    # Messages to the list owner/administrator.
    owner = 3
    # Messages to the list's posting address.
    postings = 4


@public
Beispiel #9
0
import sys
import logging
import mailman.config.config
import mailman.core.logging

from mailman.interfaces.database import IDatabaseFactory
from pkg_resources import resource_string as resource_bytes
from public import public
from zope.component import getUtility
from zope.configuration import xmlconfig

# The test infrastructure uses this to prevent the search and loading of any
# existing configuration file.  Otherwise the existence of say a
# ~/.mailman.cfg file can break tests.
INHIBIT_CONFIG_FILE = object()
public(INHIBIT_CONFIG_FILE=INHIBIT_CONFIG_FILE)


def search_for_configuration_file():
    """Search the file system for a configuration file to use.

    This is only called if the -C command line argument was not given.
    """
    config_path = os.getenv('MAILMAN_CONFIG_FILE')
    # Both None and the empty string are considered "missing".
    if config_path and os.path.exists(config_path):
        return os.path.abspath(config_path)
    # ./mailman.cfg
    config_path = os.path.abspath('mailman.cfg')
    if os.path.exists(config_path):
        return config_path
Beispiel #10
0
        cls.httpd = HTTPServer(('localhost', 8180), TestableHandler)
        cls._thread = threading.Thread(target=cls.httpd.serve_forever)
        cls._thread.daemon = True
        cls._thread.start()
        wait_for_webservice('localhost', 8180)

    @classmethod
    def tearDown(cls):
        assert cls.httpd is not None, 'Layer not set up'
        cls.httpd.shutdown()
        cls.httpd.server_close()
        cls._thread.join()


# For flufl.testing -- define this doctest's layer.
public(layer=HTTPLayer)

# Response texts.
WELCOME_1 = """\
Welcome to the "$list_name" mailing list!

To post to this list, send your email to:

  $fqdn_listname

There is a Code of Conduct for this mailing list which you can view at
http://www.example.com/code-of-conduct.html
"""

WELCOME_2 = """\
I'm glad you made it!
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from tempfile import gettempdir, mkstemp, mkdtemp
from public import public

__all__ = ["TMPDIR"]

public(gettempdir)

TMPDIR = gettempdir()


@public
def tempfile():
    """Create temp file"""
    return mkstemp()[1]


@public
def tempdir():
    """create temp dir"""
    return mkdtemp()
Beispiel #12
0
# Constants for improved readability in detector classes.  Use these like so:
#
# - to signal that no temporary or permanent failures were found:
#   `return NoFailures`
# - to signal that no temporary failures, but some permanent failures were
#   found:
#   `return NoTemporaryFailures, my_permanent_failures`
# - to signal that some temporary failures, but no permanent failures were
#   found:
#   `return my_temporary_failures, NoPermanentFailures`

NoTemporaryFailures = NoPermanentFailures = ()
NoFailures = (NoTemporaryFailures, NoPermanentFailures)

public(NoTemporaryFailures=NoTemporaryFailures)
public(NoPermanentFailures=NoPermanentFailures)
public(NoFailures=NoFailures)


@public
class IBounceDetector(Interface):
    """Detect a bounce in an email message."""
    def process(self, msg):
        """Scan an email message looking for bounce addresses.

        :param msg: An email message.
        :type msg: `Message`
        :return: A 2-tuple of the detected temporary and permanent bouncing
            addresses.  Both elements of the tuple are sets of string
            email addresses.  Not all detectors can tell the difference
import logging
import datetime

from logging import NullHandler
from public import public

DEFAULT_LOCK_LIFETIME = datetime.timedelta(seconds=15)
# Allowable a bit of clock skew.
CLOCK_SLOP = datetime.timedelta(seconds=10)
MAXINT = sys.maxsize

# Details separator; also used in calculating the claim file path.  Lock files
# should not include this character.  We do it like this so flake8 won't
# complain about SEP.
SEP = ('^' if sys.platform == 'win32' else '|')
public(SEP=SEP)

# LP: #977999 - catch both ENOENT and ESTALE.  The latter is what an NFS
# server should return, but some Linux versions return ENOENT.
ERRORS = (errno.ENOENT, errno.ESTALE)

log = logging.getLogger('flufl.lock')

# Install a null handler to avoid warnings when applications don't set their
# own flufl.lock logger.  See http://docs.python.org/library/logging.html
logging.getLogger('flufl.lock').addHandler(NullHandler())


@public
class LockError(Exception):
    """Base class for all exceptions in this module."""
Beispiel #14
0
# Copyright (C) 2013-2016 Barry A. Warsaw
#
# This file is part of world
#
# world is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, version 3 of the License.
#
# world is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# world.  If not, see <http://www.gnu.org/licenses/>.

from public import public

__version__ = '4.0'
public(__version__=__version__)
Beispiel #15
0
    def release_downloads(self, package_name, version):
        """
Retrieve a list of files and download count
        """
        return dict(self._ServerProxy.release_downloads(package_name, version))

    def release_urls(self, pkg, version):
        """
Retrieve a list of download URLs for the given package release
Returns a list of dicts with the following key
        """
        response = self._ServerProxy.release_urls(pkg, version)
        l = []
        for d in response:
            dt = datetime.datetime.strptime(str(d["upload_time"]))
            d["upload_time"] = dt.isoformat()
            l.append(d)
        return l

    def user_packages(self, user):
        """
Retrieve a list of [role_name, package_name] for a given username
Role is either 'Maintainer' or 'Owner'
        """
        return self._ServerProxy.user_packages(user)


pypi = Server('https://pypi.python.org/pypi')
public(pypi)
Beispiel #16
0
#!/usr/bin/env python
# from git.config import GitConfigParser
from gitconfigparser import GitConfigParser
from conf import Conf
from fullpath import fullpath
from public import public


@public
class GitConfig(Conf):
    read_only = False

    def __init__(self, path, read_only=False):
        self.read_only = read_only
        path = fullpath(path)
        parser = GitConfigParser(path, read_only=self.read_only)
        Conf.__init__(self, path=path, parser=parser)

    def write(self):
        self.parser.write()

gitconfig = GitConfig("~/.gitconfig", True)
public(gitconfig)
Beispiel #17
0
# Copyright (C) 2014-2019 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <https://www.gnu.org/licenses/>.
"""Alembic configuration initization."""

from alembic.config import Config
from contextlib import ExitStack
from mailman.utilities.modules import expand_path
from public import public

with ExitStack() as resources:
    cfg_path = expand_path(resources, 'python:mailman.config.alembic')
    public(alembic_cfg=Config(cfg_path))
Beispiel #18
0
# Copyright (C) 2009-2019 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <https://www.gnu.org/licenses/>.
"""General Mailman doc tests."""

from mailman.testing.layers import ConfigLayer
from public import public

public(layer=ConfigLayer)
Beispiel #19
0
from ._scan import all_failures, scan_message
from public import public

__version__ = '3.0'

public(__version__=__version__)
public(all_failures=all_failures)
public(scan_message=scan_message)
Beispiel #20
0
    buckets = rlz.scalar(rlz.integer)
    output_dtype = dt.int64


@public
class FirstValue(Analytic):
    """Retrieve the first element."""

    arg = rlz.column(rlz.any)
    output_dtype = rlz.dtype_like("arg")


@public
class LastValue(Analytic):
    """Retrieve the last element."""

    arg = rlz.column(rlz.any)
    output_dtype = rlz.dtype_like("arg")


@public
class NthValue(Analytic):
    """Retrieve the Nth element."""

    arg = rlz.column(rlz.any)
    nth = rlz.integer
    output_dtype = rlz.dtype_like("arg")


public(WindowOp=Window, AnalyticOp=Analytic)
Beispiel #21
0
public(
    any=any,
    null=null,
    boolean=boolean,
    int8=int8,
    int16=int16,
    int32=int32,
    int64=int64,
    uint8=uint8,
    uint16=uint16,
    uint32=uint32,
    uint64=uint64,
    float16=float16,
    float32=float32,
    float64=float64,
    string=string,
    binary=binary,
    date=date,
    time=time,
    timestamp=timestamp,
    dtype=dtype,
    infer=infer,
    castable=castable,
    same_kind=same_kind,
    interval=interval,
    category=category,
    geometry=geometry,
    geography=geography,
    point=point,
    linestring=linestring,
    polygon=polygon,
    multilinestring=multilinestring,
    multipoint=multipoint,
    multipolygon=multipolygon,
    json=json,
    jsonb=jsonb,
    uuid=uuid,
    macaddr=macaddr,
    inet=inet,
    decimal=decimal,
)
Beispiel #22
0
from mailman.config import config
from public import public
from sqlalchemy.ext.declarative import declarative_base


class ModelMeta:
    """The custom metaclass for all model base classes.

    This is used in the test suite to quickly reset the database after each
    test.  It works by iterating over all the tables, deleting each.  The test
    suite will then recreate the tables before each test.
    """
    @staticmethod
    def _reset(db):
        with closing(config.db.engine.connect()) as connection:
            transaction = connection.begin()
            try:
                # Delete all the tables in reverse foreign key dependency
                # order.  http://tinyurl.com/on8dy6f
                for table in reversed(Model.metadata.sorted_tables):
                    connection.execute(table.delete())
            except:  # noqa: E722 pragma: nocover
                transaction.rollback()
                raise
            else:
                transaction.commit()


Model = declarative_base(cls=ModelMeta)
public(Model=Model)
Beispiel #23
0
"""Various constants and enumerations."""

from mailman.config import config
from mailman.interfaces.languages import ILanguageManager
from mailman.interfaces.member import DeliveryMode, DeliveryStatus
from mailman.interfaces.preferences import IPreferences
from public import public
from zope.component import getUtility
from zope.interface import implementer


@implementer(IPreferences)
class SystemDefaultPreferences:
    """The default system preferences."""

    acknowledge_posts = False
    hide_address = True
    receive_list_copy = True
    receive_own_postings = True
    delivery_mode = DeliveryMode.regular
    delivery_status = DeliveryStatus.enabled

    @property
    def preferred_language(self):
        """Return the system preferred language."""
        return getUtility(ILanguageManager)[config.mailman.default_language]


public(system_preferences=SystemDefaultPreferences())
Beispiel #24
0
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
"""Internationalization."""

import mailman.messages

from flufl.i18n import PackageStrategy, registry
from mailman.interfaces.configuration import ConfigurationUpdatedEvent
from public import public

public(_=None)


@public
def initialize(application=None):
    """Initialize the i18n subsystem.

    :param application: An optional `flufl.i18n.Application` instance to use
        as the translation context.  This primarily exists to support the
        testing environment.
    :type application: `flufl.i18n.Application`
    """
    global _
    if application is None:
        strategy = PackageStrategy('mailman', mailman.messages)
        application = registry.register(strategy)
Beispiel #25
0
# Copyright (C) 2008-2021 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <https://www.gnu.org/licenses/>.

"""Mailman configuration package."""

from mailman.config.config import Configuration
from public import public


public(config=Configuration())
Beispiel #26
0
# Copyright (C) 2014-2018 by the Free Software Foundation, Inc.
#
# This file is part of GNU Mailman.
#
# GNU Mailman is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# GNU Mailman.  If not, see <http://www.gnu.org/licenses/>.
"""Alembic configuration initization."""

from alembic.config import Config
from mailman.utilities.modules import expand_path
from public import public

public(alembic_cfg=Config(expand_path('python:mailman.config.alembic')))
Beispiel #27
0
"""Package init."""

from flufl.lock._lockfile import (AlreadyLockedError, Lock, LockError,
                                  NotLockedError, SEP, TimeOutError)
from public import public

__version__ = '3.1'

public(
    AlreadyLockedError=AlreadyLockedError,
    Lock=Lock,
    LockError=LockError,
    NotLockedError=NotLockedError,
    SEP=SEP,
    TimeOutError=TimeOutError,
    __version__=__version__,
)
Beispiel #28
0
    'xxx': 'adult entertainment',  # noqa: E203
    # USA TLDs.
    'edu': 'educational',  # noqa: E203
    'gov': 'governmental',  # noqa: E203
    'mil': 'US military',  # noqa: E203
    # These additional ccTLDs are included here even though they are not part
    # of ISO 3166.  IANA has 5 reserved ccTLDs as described here:
    #
    # http://www.iso.org/iso/en/prods-services/iso3166ma/04background-on-iso-3166/iso3166-1-and-ccTLDs.html
    #
    # but I can't find an official list anywhere.
    #
    # Note that `uk' is the common practice country code for the United
    # Kingdom.  AFAICT, the official `gb' code is routinely ignored!
    #
    # <*****@*****.**> tells me that `uk' was long in use before ISO3166
    # was adopted for top-level DNS zone names (although in the reverse order
    # like uk.ac.qmw) and was carried forward (with the reversal) to avoid a
    # large-scale renaming process as the UK switched from their old `Coloured
    # Book' protocols over X.25 to Internet protocols over IP.
    #
    # See <url:ftp://ftp.ripe.net/ripe/docs/ripe-159.txt>
    'ac': 'Ascension Island',
    'eu': 'European Union',
    'su': 'Soviet Union (historical)',
    'tp': 'East Timor (obsolete)',
    'uk': 'United Kingdom (common practice)',
}

public(gTLDs=gTLDs)
Beispiel #29
0
Use these functions to produce variable times rather than the built-in
datetime.datetime.now() and datetime.date.today().  These are better
instrumented for testing purposes.
"""

import datetime

from mailman.testing import layers
from public import public

# Python always sets the locale to 'C' locale unless the user explicitly calls
# locale.setlocale(locale.LC_ALL, '').  Since we never do this in Mailman (and
# no library better do it either!) this will safely give us expected RFC 5322
# Date headers.
public(RFC822_DATE_FMT='%a, %d %b %Y %H:%M:%S %z')

# Definition of UTC timezone, taken from
# https://docs.python.org/3/library/datetime.html
ZERO = datetime.timedelta(0)


@public
class UTC(datetime.tzinfo):
    def utcoffset(self, dt):
        return ZERO

    def tzname(self, dt):
        return 'UTC'

    def dst(self, dt):
Beispiel #30
0
public(
    any=any,
    null=null,
    boolean=boolean,
    int8=int8,
    int16=int16,
    int32=int32,
    int64=int64,
    uint8=uint8,
    uint16=uint16,
    uint32=uint32,
    uint64=uint64,
    float16=float16,
    float32=float32,
    float64=float64,
    string=string,
    binary=binary,
    date=date,
    time=time,
    timestamp=timestamp,
    dtype=dtype,
    infer=infer,
    castable=castable,
    same_kind=same_kind,
    interval=interval,
    category=category,
    geometry=geometry,
    geography=geography,
    point=point,
    linestring=linestring,
    polygon=polygon,
    multilinestring=multilinestring,
    multipoint=multipoint,
    multipolygon=multipolygon,
    json=json,
    jsonb=jsonb,
    uuid=uuid,
    macaddr=macaddr,
    inet=inet,
    decimal=decimal,
)
Beispiel #31
0
# Copyright (c) 2004-2020 Adam Karpierz
# Licensed under CC BY-NC-ND 4.0
# Licensed under proprietary License
# Please refer to the accompanying LICENSE file.

from public import public
import jni
from jni._util import get_config, make_config

public(get_config=get_config)
public(make_config=make_config)


def str2jchars(val):
    jbuf = val.encode("utf-16")[jni.sizeof(jni.jchar):]  # skip byte-order mark
    jchars = jni.cast(jni.as_cstr(jbuf), jni.POINTER(jni.jchar))
    size = len(jbuf) // jni.sizeof(jni.jchar)
    return jchars, size, jbuf
        """
Retrieve a list of files and download count
        """
        return dict(
            self._ServerProxy.release_downloads(package_name, version)
        )

    def release_urls(self, pkg, version):
        """
Retrieve a list of download URLs for the given package release
Returns a list of dicts with the following key
        """
        response = self._ServerProxy.release_urls(pkg, version)
        l = []
        for d in response:
            dt = datetime.datetime.strptime(str(d["upload_time"]))
            d["upload_time"] = dt.isoformat()
            l.append(d)
        return l

    def user_packages(self, user):
        """
Retrieve a list of [role_name, package_name] for a given username
Role is either 'Maintainer' or 'Owner'
        """
        return self._ServerProxy.user_packages(user)


pypi = Server('https://pypi.python.org/pypi')
public(pypi)