def fake_upload_from_url(url): """ Return a 'fake' upload data record, so that upload errors can be mitigated by using an original / alternative URL. """ return parts.Bunch(image=parts.Bunch( animated='false', bandwidth=0, caption=None, views=0, deletehash=None, hash=None, name=(url.rsplit('/', 1) + [url])[1], title=None, type='image/*', width=0, height=0, size=0, datetime=fmt.iso_datetime(), ), links=parts.Bunch( delete_page=None, imgur_page=None, original=url, large_thumbnail=url, small_square=url, ))
def fake_upload_from_url(url): """ Return a 'fake' upload data record, so that upload errors can be mitigated by using an original / alternative URL. """ return parts.Bunch( image=parts.Bunch( animated='false', bandwidth=0, caption=None, views=0, deletehash=None, hash=None, name=(url.rsplit('/', 1) + [url])[1], title=None, type='image/*', width=0, height=0, size=0, datetime=fmt.iso_datetime(), ), links=parts.Bunch( delete_page=None, imgur_page=None, original=url, large_thumbnail=url, small_square=url, ))
def test_fmt_iso_datetime_optional_value(): result = (fmt.iso_datetime(86400), fmt.iso_datetime_optional(86400)) assert result[0] == result[1]
def test_fmt_iso_datetime_now(): result = fmt.iso_datetime() assert result.startswith('20')
def test_fmt_iso_datetime(): result = (fmt.iso_datetime(0), fmt.iso_datetime(12 * 3600), fmt.iso_datetime(23 * 3600)) assert any("1970-01-01 " in i for i in result)
def test_iso_datetime_optional(self): result = (fmt.iso_datetime(86400), fmt.iso_datetime_optional(86400)) assert result[0] == result[1] result = [fmt.iso_datetime_optional(i) for i in (0, "", None, False)] assert all(i == "never" for i in result)
def test_iso_datetime(self): result = (fmt.iso_datetime(0), fmt.iso_datetime(12*3600), fmt.iso_datetime(23*3600)) assert any("1970-01-01 " in i for i in result)
files = [x[len(folder + os.sep):] for x in files] files = [ x for x in files if not any(fnmatch.fnmatch(x, i) for i in rc_ignore) ] if not files: self.LOG.warning( "Pattern '{}' did not resolve to any files!".format( pattern)) conf_dirs[folder] = files # Write ".rc" files for folder, files in conf_dirs.items(): conf_rc = [ "# Include for '{}', generated {}".format( os.path.basename(folder), fmt.iso_datetime()) ] folder = folder.replace( os.path.expanduser('~') + os.sep, '~' + os.sep) for name in sorted(files): conf_rc.append('import = "{}{}{}"'.format( folder, os.sep, name)) self.LOG.info("Creating %r..." % (folder + '/.import.rc', )) with open(os.path.expanduser(folder + '/.import.rc'), 'wt') as handle: handle.write('\n'.join(conf_rc + [''])) elif self.options.dump_rc: # list all dynamic commands proxy = config.engine.open()