Did I find the right examples for you? yes no      Crawl my project      Python Jobs

All Samples(12)  |  Call(10)  |  Derive(0)  |  Import(2)
>>> import time
>>> t = before_timestamp_from_options({'hours': 4})
>>> time.time() - t - 4 * 60 * 60 < 1
True

        def before_timestamp_from_options(conf):
    """
    >>> import time
    >>> t = before_timestamp_from_options({'hours': 4})
    >>> time.time() - t - 4 * 60 * 60 < 1
    True
    """
    if 'time' in conf:
        try:
            return timestamp_from_isodate(conf['time'])
        except ValueError:
            raise SeedConfigurationError(
                "can't parse time '%s'. should be ISO time string" % (conf["time"], ))
    if 'mtime' in conf:
        datasource = abspath(conf['mtime'])
        try:
            return os.path.getmtime(datasource)
        except OSError, ex:
            raise SeedConfigurationError(
                "can't parse last modified time from file '%s'." % (datasource, ), ex)
    deltas = {}
    for delta_type in ('weeks', 'days', 'hours', 'minutes', 'seconds'):
        deltas[delta_type] = conf.get(delta_type, 0)
    return timestamp_before(**deltas)
        


src/m/a/MapProxy-1.6.0/mapproxy/test/unit/test_seed.py   MapProxy(Download)
from mapproxy.srs import SRS
from mapproxy.util.coverage import BBOXCoverage, GeomCoverage
from mapproxy.seed.config import before_timestamp_from_options, SeedConfigurationError
from mapproxy.seed.config import LevelsList, LevelsRange, LevelsResolutionList, LevelsResolutionRange
from mapproxy.seed.util import ProgressStore
    def test_from_time(self):
        ts = before_timestamp_from_options({'time': '2010-12-01T20:12:00'})
        # we don't know the timezone this test will run
        assert (1291230720.0 - 14 * 3600) < ts < (1291230720.0 + 14 * 3600)
 
    def test_from_mtime(self):
        with TempFile() as tmp:
            os.utime(tmp, (12376512, 12376512))
            eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
    def test_from_mtime_missing_file(self):
        before_timestamp_from_options({'mtime': '/tmp/does-not-exist-at-all,really'})
 
    def test_from_empty(self):
        assert_almost_equal(
            before_timestamp_from_options({}),

src/m/a/mapproxy-HEAD/mapproxy/test/unit/test_seed.py   mapproxy(Download)
from mapproxy.srs import SRS
from mapproxy.util.coverage import BBOXCoverage, GeomCoverage
from mapproxy.seed.config import before_timestamp_from_options, SeedConfigurationError
from mapproxy.seed.config import LevelsList, LevelsRange, LevelsResolutionList, LevelsResolutionRange
from mapproxy.seed.util import ProgressStore
    def test_from_time(self):
        ts = before_timestamp_from_options({'time': '2010-12-01T20:12:00'})
        # we don't know the timezone this test will run
        assert (1291230720.0 - 14 * 3600) < ts < (1291230720.0 + 14 * 3600)
 
    def test_from_mtime(self):
        with TempFile() as tmp:
            os.utime(tmp, (12376512, 12376512))
            eq_(before_timestamp_from_options({'mtime': tmp}), 12376512)
    def test_from_mtime_missing_file(self):
        before_timestamp_from_options({'mtime': '/tmp/does-not-exist-at-all,really'})
 
    def test_from_empty(self):
        assert_almost_equal(
            before_timestamp_from_options({}),