<s> """<STR_LIT>""" <EOL> import sys <EOL> import os . path <EOL> import datetime <EOL> import distutils . dir_util <EOL> import re <EOL> import time <EOL> import logging <EOL> try : <EOL> from configparser import ConfigParser <EOL> except ImportError : <EOL> import ConfigParser <EOL> class ClientState ( object ) : <EOL> """<STR_LIT:U+0020>""" <EOL> def __init__ ( self ) : <EOL> self . status_file = '<STR_LIT>' <EOL> def set_state ( self , site , timestamp = None ) : <EOL> """<STR_LIT>""" <EOL> parser = ConfigParser . SafeConfigParser ( ) <EOL> parser . read ( self . status_file ) <EOL> status_section = '<STR_LIT>' <EOL> if ( not parser . has_section ( status_section ) ) : <EOL> parser . add_section ( status_section ) <EOL> if ( timestamp is None ) : <EOL> parser . remove_option ( status_section , self . config_site_to_name ( site ) ) <EOL> else : <EOL> parser . set ( status_section , self . config_site_to_name ( site ) , str ( timestamp ) ) <EOL> with open ( self . status_file , '<STR_LIT:wb>' ) as configfile : <EOL> parser . write ( configfile ) <EOL> configfile . close ( ) <EOL> def get_state ( self , site ) : <EOL> """<STR_LIT>""" <EOL> parser = ConfigParser . SafeConfigParser ( ) <EOL> status_section = '<STR_LIT>' <EOL> parser . read ( self . status_file ) <EOL> timestamp = None <EOL> try : <EOL> timestamp = float ( parser . get ( status_section , self . config_site_to_name ( site ) ) ) <EOL> except ConfigParser . NoSectionError as e : <EOL> pass <EOL> except ConfigParser . NoOptionError as e : <EOL> pass <EOL> return ( timestamp ) <EOL> def config_site_to_name ( self , name ) : <EOL> return ( re . sub ( r"<STR_LIT>" , '<STR_LIT:_>' , name ) ) </s>
