<s> import os <EOL> import re <EOL> import json <EOL> from dateutil import tz <EOL> import dateutil . parser <EOL> from datetime import datetime <EOL> def make_dict ( s ) : <EOL> chunks = re . split ( '<STR_LIT>' , s ) <EOL> res = { } <EOL> args = [ reversed ( chunks ) ] * <NUM_LIT:2> <EOL> for value , key in zip ( * args ) : <EOL> key = key . rstrip ( '<STR_LIT::>' ) <EOL> if value : <EOL> res [ key ] = value <EOL> else : <EOL> res = { key : res } <EOL> return res <EOL> def writeJson ( file , data ) : <EOL> if os . path . exists ( file ) : <EOL> os . remove ( file ) <EOL> with open ( file , '<STR_LIT:w>' ) as dump : <EOL> json . dump ( data , dump , indent = <NUM_LIT:2> ) <EOL> def toLocalTime ( utc ) : <EOL> timezone = tz . tzlocal ( ) <EOL> utc = dateutil . parser . parse ( utc ) <EOL> output = utc . astimezone ( timezone ) <EOL> output = output . strftime ( '<STR_LIT>' ) <EOL> return output <EOL> def fromEpoch ( epoch ) : <EOL> return datetime . fromtimestamp ( epoch ) . strftime ( '<STR_LIT>' ) <EOL> def toHuman ( cpe ) : <EOL> cpe = cpe [ <NUM_LIT:7> : ] <EOL> result = cpe . split ( '<STR_LIT::>' ) [ <NUM_LIT:0> ] + "<STR_LIT>" <EOL> for c in cpe . split ( '<STR_LIT::>' ) [ <NUM_LIT:1> : ] : <EOL> c = c . replace ( '<STR_LIT::>' , '<STR_LIT:U+0020>' ) <EOL> c = c . replace ( '<STR_LIT:_>' , '<STR_LIT:U+0020>' ) <EOL> result += ( "<STR_LIT>" % ( c ) ) <EOL> result = result . title ( ) <EOL> return result <EOL> def splitByLength ( string , size = <NUM_LIT:50> ) : <EOL> return [ string [ i : i + size ] for i in range ( <NUM_LIT:0> , len ( string ) , size ) ] </s>
