forked from HawksRepos/PTS-Team
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MrDoobPG
authored and
MrDoobPG
committed
Nov 6, 2019
1 parent
b21acf5
commit 3b5233e
Showing
19 changed files
with
427 additions
and
316 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from misc.log import logger | ||
|
||
log = logger.get_logger(__name__) | ||
|
||
|
||
def get_year_from_timestamp(timestamp): | ||
year = 0 | ||
try: | ||
if not timestamp: | ||
return 0 | ||
|
||
year = timestamp[:timestamp.index('-')] | ||
except Exception: | ||
log.exception("Exception parsing year from %s: ", timestamp) | ||
return int(year) if str(year).isdigit() else 0 | ||
|
||
|
||
def is_ascii(string): | ||
try: | ||
string.encode('ascii') | ||
except UnicodeEncodeError: | ||
return False | ||
except UnicodeDecodeError: | ||
return False | ||
except Exception: | ||
log.exception(u"Exception checking if %r was ascii: ", string) | ||
return False | ||
return True | ||
|
||
|
||
def ensure_endswith(data, endswith_key): | ||
if not data.strip().endswith(endswith_key): | ||
return "%s%s" % (data.strip(), endswith_key) | ||
else: | ||
return data |
Oops, something went wrong.