diff options
author | biao716.wang <biao716.wang@samsung.com> | 2022-11-08 19:24:37 +0900 |
---|---|---|
committer | biao716.wang <biao716.wang@samsung.com> | 2022-11-08 19:34:45 +0900 |
commit | 1581486ef8bd3a30bd30085ec8472de38a042b8f (patch) | |
tree | c96351e62077dc7e846d7e5f2d97b56c2f0e23a4 | |
parent | 24ef1a0189ce85d3425b45d6229959eec9d59cda (diff) | |
download | git-buildpackage-1581486ef8bd3a30bd30085ec8472de38a042b8f.tar.gz git-buildpackage-1581486ef8bd3a30bd30085ec8472de38a042b8f.tar.bz2 git-buildpackage-1581486ef8bd3a30bd30085ec8472de38a042b8f.zip |
replace rfc822 to dateutil
Change-Id: I401cec4eb4057ff54b27ed25d9a32bd0e455cefe
Signed-off-by: biao716.wang <biao716.wang@samsung.com>
-rwxr-xr-x | debian/control | 2 | ||||
-rw-r--r-- | gbp/git/__init__.py | 30 |
2 files changed, 7 insertions, 25 deletions
diff --git a/debian/control b/debian/control index ac77e57b..afd3198c 100755 --- a/debian/control +++ b/debian/control @@ -15,6 +15,7 @@ Build-Depends: python3-nose, python3-pkg-resources, python3-setuptools, + python3-dateutil, sgml2x, librpm-tizen, # For rpm (epydoc) @@ -34,6 +35,7 @@ Depends: ${python3:Depends}, git (>= 1:1.7.9.1-1~), man-db, python3-pkg-resources, + python3-dateutil, #unittest need zipmerge Recommends: pristine-tar (>= 0.5) diff --git a/gbp/git/__init__.py b/gbp/git/__init__.py index cbd84cb5..57b74eff 100644 --- a/gbp/git/__init__.py +++ b/gbp/git/__init__.py @@ -17,8 +17,7 @@ """Accessing Git from python""" import calendar -import datetime -import rfc822 +import dateutil.parser from gbp.git.modifier import GitModifier from gbp.git.commit import GitCommit @@ -29,26 +28,8 @@ from gbp.git.args import GitArgs from gbp.git.vfs import GitVfs -class FixedOffset(datetime.tzinfo): - """Fixed offset in seconds east from UTC.""" - - ZERO = datetime.timedelta(0) - - def __init__(self, offset): - datetime.tzinfo.__init__(self) - self._offset = datetime.timedelta(seconds=offset) - - def utcoffset(self, dtime): - return self._offset + self.dst(dtime) - - def dst(self, dtime): - assert dtime.tzinfo is self - return self.ZERO - - def rfc822_date_to_git(rfc822_date): """Parse a date in RFC822 format, and convert to a 'seconds tz' C{str}ing. - >>> rfc822_date_to_git('Thu, 1 Jan 1970 00:00:01 +0000') '1 +0000' >>> rfc822_date_to_git('Thu, 20 Mar 2008 01:12:57 -0700') @@ -56,10 +37,9 @@ def rfc822_date_to_git(rfc822_date): >>> rfc822_date_to_git('Sat, 5 Apr 2008 17:01:32 +0200') '1207407692 +0200' """ - parsed = rfc822.parsedate_tz(rfc822_date) - date = datetime.datetime(*parsed[:6], tzinfo=FixedOffset(parsed[-1])) - seconds = calendar.timegm(date.utctimetuple()) - tzone = date.strftime("%z") - return '%d %s' % (seconds, tzone) + d = dateutil.parser.parse(rfc822_date) + seconds = calendar.timegm(d.utctimetuple()) + tz = d.strftime("%z") + return '%d %s' % (seconds, tz) # vim:et:ts=4:sw=4:et:sts=4:ai:set list listchars=tab\:»·,trail\:·: |