当前位置: 首页>>代码示例>>Python>>正文


Python delorean.Delorean类代码示例

本文整理汇总了Python中delorean.Delorean的典型用法代码示例。如果您正苦于以下问题:Python Delorean类的具体用法?Python Delorean怎么用?Python Delorean使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Delorean类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: process_item

    def process_item(self, item, spider):
        if 'search_results' not in getattr(spider,'pipelines',[]):
            return item

        dt = Delorean()

        item['id'] = item['id'][0]
        item['auction_id'] = item['auction_id'][0]
        item['site'] = item['site'][0]
        item['link'] = item['link'][0]
        item['name'] = item['name'][0]
        item['price'] = ','.join([x.replace(',','').replace('$','') for x in item['price']]) if 'price' in item else 0
        item['modified'] = int(dt.epoch())

        existing_record = Session().query(AuctionItem)\
            .filter(AuctionItem.id == item['id'])\
            .filter(AuctionItem.auction_id == item['auction_id']).all()

        item = AuctionItem(**item)

        if existing_record is not None:
            item.update()
        else:
            item.create()
            
        return item
开发者ID:stevecoward,项目名称:auction-scraper,代码行数:26,代码来源:pipelines.py

示例2: generate_reply

def generate_reply(text, user_id):
    if not is_valid(text):
        reply_text = "Incorrect Format - Should be HH:MM (eg. 09:00 or 16:45)"
        return create_json(reply_text, user_id)

    hours   = text[0:2]
    minutes = text[3:5]

    # Handle timezone
    now = Delorean()
    now.shift("Europe/London")  # Currently only supports UK timezone

    # If today is Monday and before our target time
    if now.datetime.weekday() == 0 and (now.datetime.hour < int(hours) or (now.datetime.hour == int(hours) and now.datetime.minute < int(minutes))):
        monday = now.datetime
    else:
        monday = now.next_monday().datetime

    target = Delorean(datetime.datetime(monday.year, monday.month, monday.day, int(hours), int(minutes)), timezone='Europe/London')

    # Calculate time
    result        = (target - now)
    days_until    = result.days
    hours_until   = result.seconds / 60 / 60
    minutes_until = (result.seconds / 60) - (hours_until * 60)

    # Format message
    days_format    = "day"    if days_until == 1    else "days"
    hours_format   = "hour"   if hours_until == 1   else "hours"
    minutes_format = "minute" if minutes_until == 1 else "minutes"
    reply_text = "{} {}, {} {} and {} {} until Monday at {}:{}.".format(days_until, days_format, hours_until, hours_format, minutes_until, minutes_format, hours, minutes)
    return create_json(reply_text, user_id)
开发者ID:danstewart,项目名称:mondaybot,代码行数:32,代码来源:response.py

示例3: test_delorean_with_timezone

 def test_delorean_with_timezone(self):
     dt = datetime.utcnow()
     d = Delorean(datetime=dt, timezone=UTC)
     d = d.shift("US/Eastern")
     dt = utc.localize(dt)
     dt = est.normalize(dt)
     self.assertEqual(dt, d._dt)
     self.assertEqual(est, timezone(d._tz))
开发者ID:shussain,项目名称:delorean,代码行数:8,代码来源:test_data.py

示例4: test_delorean_with_only_timezone

 def test_delorean_with_only_timezone(self):
     dt = datetime.utcnow()
     dt = utc.localize(dt)
     dt = est.normalize(dt)
     dt = dt.replace(second=0, microsecond=0)
     d = Delorean(timezone="US/Eastern")
     d.truncate('minute')
     self.assertEqual(est, timezone(d._tz))
     self.assertEqual(dt, d._dt)
开发者ID:shussain,项目名称:delorean,代码行数:9,代码来源:test_data.py

示例5: test_range_with_start

 def test_range_with_start(self):
     dates1 = []
     for do in stops(DAILY, count=5, start=datetime.utcnow()):
         do.truncate('minute')
         dates1.append(do)
     do = Delorean().truncate('minute')
     dates2 = []
     for x in range(5):
         dates2.append(do.next_day(x))
     self.assertEqual(dates1, dates2)
开发者ID:shussain,项目名称:delorean,代码行数:10,代码来源:test_data.py

示例6: test_utc_date_time_deserialize_parse_args

    def test_utc_date_time_deserialize_parse_args(self):
        """
        UTCDateTimeAttribute.deserialize
        """
        tstamp = Delorean(timezone=UTC).datetime
        attr = UTCDateTimeAttribute()

        with patch('pynamodb.attributes.parse') as parse:
            attr.deserialize(Delorean(tstamp, timezone=UTC).datetime.strftime(DATETIME_FORMAT))

            parse.assert_called_with(tstamp.strftime(DATETIME_FORMAT), dayfirst=False)
开发者ID:RenegadeMaster,项目名称:todoangularflask_aws,代码行数:11,代码来源:test_attributes.py

示例7: test_range_with_interval

 def test_range_with_interval(self):
     dates1 = []
     for do in stops(DAILY, interval=2, count=3, start=datetime.utcnow()):
         do.truncate('minute')
         dates1.append(do)
     do = Delorean().truncate('minute')
     dates2 = []
     for x in range(6):
         if (x % 2) == 0:
             dates2.append(do.next_day(x))
     self.assertEqual(dates1, dates2)
开发者ID:shussain,项目名称:delorean,代码行数:11,代码来源:test_data.py

示例8: test_range_with_start_and_stop

 def test_range_with_start_and_stop(self):
     dates1 = []
     tomorrow = datetime.utcnow() + timedelta(days=1)
     for do in stops(DAILY, start=datetime.utcnow(), until=tomorrow):
         do.truncate('minute')
         dates1.append(do)
     do = Delorean().truncate('minute')
     dates2 = []
     for x in range(2):
         dates2.append(do.next_day(x))
     self.assertEqual(dates1, dates2)
开发者ID:shussain,项目名称:delorean,代码行数:11,代码来源:test_data.py

示例9: get_next_trading_dt

def get_next_trading_dt(current, interval):
    naive = current.replace(tzinfo=None)
    delo = Delorean(naive, pytz.utc.zone)
    ex_tz = trading.environment.exchange_tz
    next_dt = delo.shift(ex_tz).datetime

    while True:
        next_dt = next_dt + interval
        next_delo = Delorean(next_dt.replace(tzinfo=None), ex_tz)
        next_utc = next_delo.shift(pytz.utc.zone).datetime
        if trading.environment.is_market_hours(next_utc):
            break

    return next_utc
开发者ID:BroadBeard,项目名称:zipline,代码行数:14,代码来源:factory.py

示例10: create_app

def create_app(environment, port):
    flask = Flask(__name__)
    flask.config.from_pyfile('config.py')

    config = load_config(environment)
    with open('info.json', 'r') as configFile:
        info = json.loads(configFile.read())

    view_util.navigation_bar = navigation_bar
    view_util.app_name = info['name']

    status.blueprint.navigation_bar = navigation_bar
    status.blueprint.info = info
    status.blueprint.environment = environment
    status.blueprint.port = port
    status.blueprint.start_time = Delorean.now()

    mongo = MongoConnect(config)

    views.blueprint.mongo = mongo
    views.blueprint.config = config['app']
    api.blueprint.mongo = mongo
    api.blueprint.config = config['app']

    flask.register_blueprint(status.blueprint)
    flask.register_blueprint(views.blueprint)
    flask.register_blueprint(api.blueprint)
    return flask
开发者ID:otto-de,项目名称:gatekeeper,代码行数:28,代码来源:app.py

示例11: generate_status

def generate_status():
    now = Delorean.now()
    uptime = (now - (now - blueprint.start_time)).humanize()

    return {
        "application": {
            "name": blueprint.info["name"],
            "description": blueprint.info["description"],
            "group": blueprint.info["group"],
            "environment": blueprint.environment,
            "version": blueprint.info["version"],
            "commit": blueprint.info["commit"],
            "vcs_link": blueprint.info["vcs_link"] + blueprint.info["commit"],
            "status": "OK",
            "statusDetails": {},
        },
        "system": {
            "hostname": socket.gethostname(),
            "port": blueprint.port,
            "systemtime": now.format_datetime(format=get_timestamp_format()),
            "systemstarttime": blueprint.start_time.format_datetime(format=get_timestamp_format()),
            "uptime": uptime,
        },
        "team": {
            "team": blueprint.info["team"],
            "contact_technical": blueprint.info["contact_technical"],
            "contact_business": blueprint.info["contact_business"],
        },
        "serviceSpecs": {},
    }
开发者ID:otto-de,项目名称:gatekeeper,代码行数:30,代码来源:status.py

示例12: __init__

class MongoConnect:
    def __init__(self, config):
        self.client = MongoClient(config["mongo"]["uris"])
        self.db = self.client[config["mongo"]["database"]]
        self.collection = self.db[config["mongo"]["collection"]]
        self.d = Delorean()
        self.d = self.d.shift("Europe/Amsterdam")
开发者ID:redvox,项目名称:hard-starboard,代码行数:7,代码来源:mongo_connect.py

示例13: get_local_time

def get_local_time(date, ip):
    reader = geoip2.database.Reader('/Users/scoward/Downloads/GeoIP2-City_20140930/GeoIP2-City.mmdb')
    
    if ip == '127.0.0.1':
        ip = '71.224.243.72'
        # ip = '167.29.0.143'
        # ip = '85.158.202.2'

    response = reader.city(ip)
    local_time_zone = response.location.time_zone

    shifted_date = Delorean(date, 'UTC')
    shifted_date.shift(local_time_zone)
    shifted_date = shifted_date.datetime.strftime('%Y-%m-%d %H:%M:%S')

    return shifted_date
开发者ID:idkwim,项目名称:ctf-manager,代码行数:16,代码来源:utils.py

示例14: parse_query_value

def parse_query_value(query_str, tf):
    """ Return value for the query string """
    try:
        query_str = str(query_str).strip('"\' ')
        if query_str == 'now':
            d = Delorean(timezone=tf)
        else:
            # Parse datetime string or timestamp
            try:
                d = epoch(float(query_str))
                d.shift(tf);
            except ValueError:
                d = parse(str(query_str))
                d.shift(tf);
    except (TypeError, ValueError):
        d = None
    return d
开发者ID:hellowangit,项目名称:alfred-datetime-format-converter,代码行数:17,代码来源:process.py

示例15: __init__

 def __init__(self, config):
     self.client = MongoClient(config['mongo']['uris'])
     self.db = self.client[config['mongo']['database']]
     self.collection = self.db[config['mongo']['services_collection']]
     self.tickets = self.db[config['mongo']['tickets_collection']]
     self.queue = self.db['queue']
     self.d = Delorean()
     self.d = self.d.shift('Europe/Amsterdam')
开发者ID:otto-de,项目名称:gatekeeper,代码行数:8,代码来源:mongo_connect.py


注:本文中的delorean.Delorean类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。