本文整理汇总了Python中options.Options方法的典型用法代码示例。如果您正苦于以下问题:Python options.Options方法的具体用法?Python options.Options怎么用?Python options.Options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类options
的用法示例。
在下文中一共展示了options.Options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: train
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def train():
""" Training
"""
##
# ARGUMENTS
opt = Options().parse()
##
# LOAD DATA
dataloader = load_data(opt)
##
# LOAD MODEL
model = Ganomaly(opt, dataloader)
##
# TRAIN MODEL
model.train()
示例2: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the Http class."""
self.options = Options()
self.options.add_option('url', 'http://127.0.0.1:80/', 'Host to connect to')
self.options.add_option('separator', 'newline', 'Separator between elements',
list(self._SEPARATORS.keys()), True)
self.options.add_option('final_separator', False, 'Whether to end output with an instance of the separator')
self.options.add_option('number_format', 'decimal', 'Format for numbers', ['decimal', 'hexadecimal', 'octal'])
# TODO - eventually support PUT, DELETE, HEAD, and OPTIONS, since requests easily handles those
self.options.add_option('http_method', 'GET', 'Type of HTTP request to make', ['POST', 'GET'])
self.options.add_option('content_type', '', 'Content-Type header for the HTTP request')
self.options.add_option('url_param_name', 'param', 'Name of URL arg(s) to use')
self.options.add_option('spread_params', True, 'Put each output in its own URL arg, as opposed to all in one')
self.options.add_option('use_body', False, 'Put exploit output in body, not URL args')
self.options.add_option('print_request', False, 'Print HTTP request')
self.options.add_option('send_request', True, 'Send HTTP request')
self.options.add_option('n_requests', 1, 'Total number of times to send the request')
self.options.add_option('n_parallel', 1, 'Number of requests to send simultaneously')
# TODO - eventually allow printing out http response?
示例3: build_position_index
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def build_position_index(self):
'''
Builds an array covering the entire visible screen and fills it
with references to the index items where appropriate so we can show
select boxes on hover
'''
opt = Options()
w = opt.width
h = opt.height
# 2d array of size h, w
self.item_position_index = [[None for x in xrange(w)] for y in xrange(h)]
num_displayed_items = 0
size_multiplier = 64 * opt.size_multiplier
for item in self.drawn_items:
if self.show_item(item.item):
for y in range(int(item.y), int(item.y + size_multiplier)):
if y >= h:
continue
row = self.item_position_index[y]
for x in range(int(item.x), int(item.x + size_multiplier)):
if x >= w:
continue
row[x] = num_displayed_items # Set the row to the index of the item
num_displayed_items += 1
示例4: get_image
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def get_image(self, imagename):
image = self._image_library.get(imagename)
if image is None:
path = ""
need_path = True
# if we're in antibirth mode, check if there's an antibirth version of the image first
if self.state and self.state.game_version == "Antibirth":
path = self.make_path(imagename, True)
if os.path.isfile(path):
need_path = False
if need_path:
path = self.make_path(imagename)
image = pygame.image.load(path)
size_multiplier = Options().size_multiplier
scaled_image = image
# Resize image iff we need to
if size_multiplier != 1:
scaled_image = pygame.transform.scale(image, (
int(image.get_size()[0] * size_multiplier),
int(image.get_size()[1] * size_multiplier)))
self._image_library[imagename] = scaled_image
return image
示例5: update_window_title
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def update_window_title(self):
title = ""
# The user wants a hard-coded window title
if Options().custom_title_enabled:
title = Options().custom_title
else:
title = "Rebirth Item Tracker"
if self.window_title_info.update_notifier:
title += self.window_title_info.update_notifier
if self.window_title_info.watching:
title += ", spectating " + self.window_title_info.watching_player + ". Delay: " + str(Options().read_delay) + ". Updates queued: " + str(self.window_title_info.updates_queued)
elif self.window_title_info.uploading:
title += ", uploading to server"
# Set the title on the actual window
pygame.display.set_caption(title)
示例6: reset
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def reset(self):
"""Reset variable specific to the log file/run"""
# Variables describing the parser state
self.getting_start_items = False
self.reseeding_floor = False
self.current_room = ""
self.current_seed = ""
# Cached contents of log
self.content = ""
# Log split into lines
self.splitfile = []
self.run_start_line = 0
self.seek = 0
self.spawned_coop_baby = 0
self.log_file_handle = None
# if they switched between rebirth and afterbirth, the log file we use could change
self.log_file_path = self.log_finder.find_log_file(self.wdir_prefix)
self.state.reset(self.current_seed, Options().game_version)
示例7: parse
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def parse(self):
"""
Parse the log file and return a TrackerState object,
or None if the log file couldn't be found
"""
self.opt = Options()
# Attempt to load log_file
if not self.__load_log_file():
return None
self.splitfile = self.content.splitlines()
# This will become true if we are getting starting items
self.getting_start_items = False
# Process log's new output
for current_line_number, line in enumerate(self.splitfile[self.seek:]):
self.__parse_line(current_line_number, line)
self.seek = len(self.splitfile)
return self.state
示例8: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the Stdout class."""
self.options = Options()
self.options.add_option('separator', 'newline', 'Separator between elements',
list(self._SEPARATORS.keys()), True)
self.options.add_option('number_format', 'decimal', 'Format for numbers', ['decimal', 'hexadecimal', 'octal'])
示例9: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the File class."""
self.options = Options()
self.options.add_option('filename', 'acsploit_output.dat', 'The name of the file to write to')
# TODO: add more formats
self.options.add_option('separator', 'newline', 'Separator between elements',
list(self._SEPARATORS.keys()), True)
self.options.add_option('format', 'plaintext', 'The format to write output in', ['plaintext', 'binary', 'sv', 'template'])
self.options.add_option('final_newline', True, 'Whether to end the file with a newline')
self.options.add_option('number_format', 'decimal', 'Format for numbers', ['decimal', 'hexadecimal', 'octal'])
self.options.add_option('template_file', None, 'Template file to use when "format" is "template"')
self.options.add_option('template_pattern', '<ACSPLOIT>',
'Replacement pattern in template file, marks where the payload will be copied')
self.options.add_option('replace_first_only', False,
'Whether to replace only the first occurrence of template_pattern or all occurrences')
示例10: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the Socket class."""
self.options = Options()
self.options.add_option('host', '127.0.0.1', 'Host to connect to')
self.options.add_option('port', 80, 'Port to connect to')
self.options.add_option('ip_version', 'IPv4', 'Version of IP to use', ['IPv4', 'IPv6'])
self.options.add_option('separator', 'newline', 'Separator between elements',
list(self._SEPARATORS.keys()), True)
self.options.add_option('final_separator', False, 'Whether to end output with an instance of the separator')
self.options.add_option('await_banner', False, 'Receive a banner message from the server before sending data')
self.options.add_option('number_format', 'decimal', 'Format for numbers', ['decimal', 'hexadecimal', 'octal'])
示例11: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the Regex Generator."""
self.options = Options()
self.options.add_option('regex', '.*', 'Generated strings will match this regex')
示例12: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the Chracter generator."""
self.options = Options()
self.options.add_option('min_value', 'a', 'Minimum ASCII character to use')
self.options.add_option('max_value', 'z', 'Maximum ASCII character to use')
self.options.add_option('restrictions', '', 'String of characters to exclude')
self.options.add_option('use_whitelist', False, 'If true, only generate characters from the whitelist')
self.options.add_option('whitelist', '', 'String of characters to generate from if use_whitelist is True')
# char_set will be a sorted valid set of characters given the constraints set in options
# char_set must be updated by calling prepare() if options change
self._char_set = string.ascii_lowercase
示例13: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the Float Generator."""
self.options = Options()
self.options.add_option('min_value', 0.0, 'Minimum floating point value allowed')
self.options.add_option('max_value', 255.0, 'Maximum floating point value allowed')
self._min = 0.0
self._max = 255.0
示例14: __init__
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def __init__(self):
"""Initialize the String Generator."""
self.options = Options()
self.options.add_option('min_length', 1, 'Minimum string length')
self.options.add_option('max_length', 10, 'Maximum string length')
self.options.add_option('min_value', 'a', 'Minimum ASCII character to use')
self.options.add_option('max_value', 'z', 'Maximum ASCII character to use')
self.options.add_option('restrictions', '', 'String of characters to exclude')
self.options.add_option('use_whitelist', False, 'If True, only generate characters from the whitelist')
self.options.add_option('whitelist', '', 'String of characters to generate from if use_whitelist is True')
self.char_gen = CharGenerator()
self.prepare()
示例15: find_log_file
# 需要导入模块: import options [as 别名]
# 或者: from options import Options [as 别名]
def find_log_file(self, wdir_prefix=".."):
"""
Try to find the game log file
Returns a string path, or None if we couldn't find it
"""
logfile_location = ""
version_path_fragment = Options().game_version
if version_path_fragment == "Antibirth":
version_path_fragment = "Rebirth"
if platform.system() == "Windows":
logfile_location = os.environ['USERPROFILE'] + '/Documents/My Games/Binding of Isaac {}/'
elif platform.system() == "Linux":
logfile_location = os.getenv('XDG_DATA_HOME',
os.path.expanduser('~') + '/.local/share') + '/binding of isaac {}/'
version_path_fragment = version_path_fragment.lower()
elif platform.system() == "Darwin":
logfile_location = os.path.expanduser('~') + '/Library/Application Support/Binding of Isaac {}/'
logfile_location = logfile_location.format(version_path_fragment)
for check in (wdir_prefix + '../log.txt', logfile_location + 'log.txt'):
if os.path.isfile(check):
return check
self.log.error("Couldn't find log.txt in " + logfile_location)
return None