def testFlagHelpInXML_SpaceSeparatedList(self): gflags.DEFINE_spaceseplist('dirs', 'src libs bin', 'Directories to search.', flag_values=self.fv) expected_output = ( ' <flag>\n' ' <file>tool</file>\n' ' <name>dirs</name>\n' ' <meaning>Directories to search.</meaning>\n' ' <default>src libs bin</default>\n' ' <current>[\'src\', \'libs\', \'bin\']</current>\n' ' <type>whitespace separated list of strings</type>\n' 'LIST_SEPARATORS' ' </flag>\n').replace( 'LIST_SEPARATORS', _ListSeparatorsInXMLFormat(string.whitespace, indent=' ')) self._CheckFlagHelpInXML('dirs', 'tool', expected_output)
FLAGS = flags.FLAGS flags.DEFINE_enum('action', None, ['boot', 'start', 'mini_boot', 'ping', 'kill', 'info'], 'The action to perform against the emulator images') flags.DEFINE_string( 'skin', None, '[BOOT ONLY] The skin parameter to pass ' 'to the emulator') flags.DEFINE_string('density', None, '[bazel ONLY] Density of the lcd screen') flags.DEFINE_string( 'cache', None, '[bazel ONLY] Size of cache partition in mb ' '- currently not functioning') flags.DEFINE_string('vm_size', None, '[bazel ONLY] VM heap size in mb') flags.DEFINE_integer('memory', None, '[bazel ONLY] the memory for the emulator') flags.DEFINE_spaceseplist( 'system_images', None, '[bazel ONLY] the system ' 'images to boot the emulator with') flags.DEFINE_spaceseplist('apks', None, '[START ONLY] the apks to install') flags.DEFINE_spaceseplist('system_apks', None, '[START ONLY] system apks to ' 'install') flags.DEFINE_boolean( 'preverify_apks', False, '[START ONLY] if true the apks ' 'will be preverified upon install (normal production ' 'behaviour). It defaults to disabled because some of the ' 'verification failures are overkill in the bazel ' 'environment. For example it is very easy to have ' 'both a test apk and app apk contain a ref to the ' 'same class file (eg Maps from the guava jars) and ' 'this kills the verifier (out of the fear that the ' '2 apks have different class definitions and the ' 'optimizations in the app apk will bypass the test '
import gflags FLAGS = gflags.FLAGS # Local modules from dpxdt.client import release_worker from dpxdt.client import fetch_worker from dpxdt.client import workers import flags gflags.DEFINE_integer( 'crawl_depth', -1, 'How deep to crawl. Depth of 0 means only the given page. 1 means pages ' 'that are one click away, 2 means two clicks, and so on. Set to -1 to ' 'scan every URL with the supplied prefix.') gflags.DEFINE_spaceseplist('ignore_prefixes', [], 'URL prefixes that should not be crawled.') # URL regex rewriting code originally from mirrorrr # http://code.google.com/p/mirrorrr/source/browse/trunk/transform_content.py # URLs that have absolute addresses ABSOLUTE_URL_REGEX = r"(?P<url>(http(s?):)?//[^\"'> \t]+)" # URLs that are relative to the base of the current hostname. BASE_RELATIVE_URL_REGEX = ( r"/(?!(/)|(http(s?)://)|(url\())(?P<url>[^\"'> \t]*)") # URLs that have '../' or './' to start off their paths. TRAVERSAL_URL_REGEX = (r"(?P<relative>\.(\.)?)/(?!(/)|" r"(http(s?)://)|(url\())(?P<url>[^\"'> \t]*)") # URLs that are in the same directory as the requested URL. SAME_DIR_URL_REGEX = ( r"(?!(/)|([a-z0-9.-]{2,10}:(//)?)|(#)|(url\())(?P<url>[^\\\"'> \t]+)")
import gflags # ============ Flow control gflags.DEFINE_integer('val_every_epochs', 1, 'Validation frequency, in epochs', lower_bound=1) gflags.DEFINE_spaceseplist('val_on_sets', 'valid', 'On which sets to ' 'perform validation') gflags.DEFINE_integer('val_skip_first', 0, 'How many epochs to skip before ' 'validating', lower_bound=0) gflags.DEFINE_integer('min_epochs', 1, 'The minimum number of epochs ' 'before early stopping is possible', lower_bound=1) gflags.DEFINE_integer('max_epochs', 100, 'The maximum number of epochs', lower_bound=1) gflags.DEFINE_integer('patience', 100, 'The number of validation with no ' 'improvement the model will wait before early stopping', lower_bound=1) gflags.DEFINE_bool('do_validation_only', False, 'If True does one round ' 'of validation') # Other flags we might want to define (see also config/misc.py): # early_stop_metric='subsets_avg_val_jaccard_fg', # early_stop_strategy='max', # val_every_batches=None, # validate every n batches (else epoch)
'new', False, 'New operation', short_name='n') gflags.DEFINE_boolean( 'remove', False, 'Remove operation', short_name='r') gflags.DEFINE_boolean( 'summary', False, 'Print a summmary of the task lists.', short_name='s') gflags.DEFINE_boolean( 'toggle', False, 'Toggle operation', short_name='t') gflags.DEFINE_boolean( 'quit', False, 'Quit operation', short_name='q') # Flags related to options on above operations. gflags.DEFINE_integer( 'after', -1, 'The index of the task that this should be after') gflags.DEFINE_string( 'date', '', 'A date in MM/DD/YYYY format.') gflags.DEFINE_spaceseplist( 'index', '', 'Index of task.', short_name='i') gflags.DEFINE_boolean( 'force', False, 'Forcibly perform the operation.', short_name='f') gflags.DEFINE_string( 'note', '', 'A note to attach to a task.') gflags.DEFINE_string( 'parent', '', 'Index of parent task.', short_name='p') gflags.DEFINE_string( 'rename', '', 'Rename a task list.') gflags.DEFINE_integer( 'tasklist', 0, 'Id of task list to operate on.') gflags.DEFINE_string( 'title', '', 'The name of the task.') USAGE = ('[-a]dd, [-c]lear, [-d]elete, [-e]dit, [-r]emove task, [-m]ove, ' +
def testWriteHelpInXMLFormat(self): fv = gflags.FlagValues() # Since these flags are defined by the top module, they are all key. gflags.DEFINE_integer('index', 17, 'An integer flag', flag_values=fv) gflags.DEFINE_integer('nb_iters', 17, 'An integer flag', lower_bound=5, upper_bound=27, flag_values=fv) gflags.DEFINE_string('file_path', '/path/to/my/dir', 'A test string flag.', flag_values=fv) gflags.DEFINE_boolean('use_hack', False, 'Use performance hack', flag_values=fv) gflags.DEFINE_enum('cc_version', 'stable', ['stable', 'experimental'], 'Compiler version to use.', flag_values=fv) gflags.DEFINE_list('files', 'a.cc,a.h,archive/old.zip', 'Files to process.', flag_values=fv) gflags.DEFINE_list('allow_users', ['alice', 'bob'], 'Users with access.', flag_values=fv) gflags.DEFINE_spaceseplist('dirs', 'src libs bins', 'Directories to create.', flag_values=fv) gflags.DEFINE_multistring('to_delete', ['a.cc', 'b.h'], 'Files to delete', flag_values=fv) gflags.DEFINE_multi_int('cols', [5, 7, 23], 'Columns to select', flag_values=fv) # Define a few flags in a different module. module_bar.DefineFlags(flag_values=fv) # And declare only a few of them to be key. This way, we have # different kinds of flags, defined in different modules, and not # all of them are key flags. gflags.DECLARE_key_flag('tmod_bar_z', flag_values=fv) gflags.DECLARE_key_flag('tmod_bar_u', flag_values=fv) # Generate flag help in XML format in the StringIO sio. sio = StringIO.StringIO() fv.WriteHelpInXMLFormat(sio) # Check that we got the expected result. expected_output_template = EXPECTED_HELP_XML_START main_module_name = gflags._GetMainModule() module_bar_name = module_bar.__name__ if main_module_name < module_bar_name: expected_output_template += EXPECTED_HELP_XML_FOR_FLAGS_FROM_MAIN_MODULE expected_output_template += EXPECTED_HELP_XML_FOR_FLAGS_FROM_MODULE_BAR else: expected_output_template += EXPECTED_HELP_XML_FOR_FLAGS_FROM_MODULE_BAR expected_output_template += EXPECTED_HELP_XML_FOR_FLAGS_FROM_MAIN_MODULE expected_output_template += EXPECTED_HELP_XML_END # XML representation of the whitespace list separators. whitespace_separators = _ListSeparatorsInXMLFormat(string.whitespace, indent=' ') expected_output = (expected_output_template % { 'usage_doc': sys.modules['__main__'].__doc__, 'main_module_name': main_module_name, 'module_bar_name': module_bar_name, 'whitespace_separators': whitespace_separators }) actual_output = sio.getvalue() self.assertMultiLineEqual(actual_output, expected_output) # Also check that our result is valid XML. minidom.parseString # throws an xml.parsers.expat.ExpatError in case of an error. xml.dom.minidom.parseString(actual_output)
writeTalks(f, today_talks, upcoming_talks, past_talks) writeWebsiteEpilogue(f) if __name__ == '__main__': gflags.DEFINE_string("mailer", "/usr/sbin/sendmail", "Path to mail program") gflags.DEFINE_string("data", "/nfs/amber/riesa/nl-seminar/data", "Path to NL Seminar data files") gflags.DEFINE_string("website", None, "Path to website file") gflags.DEFINE_string("ical", None, "Path to ical file.") gflags.DEFINE_boolean("debug", False, "Print verbose debugging messages.") gflags.DEFINE_string("seminar_name", "NL Seminar", "Name of Seminar") gflags.DEFINE_boolean("mail", True, "Send broadcast mail for upcoming seminars") gflags.DEFINE_spaceseplist("sender_name", "NL Seminar", "Name of the organizer of this seminar.") gflags.DEFINE_string("sender_email", "*****@*****.**", "E-mail of the organizer of this seminar.") gflags.DEFINE_multistring( "recipient", "*****@*****.**", "Recipient of announcements of this semianr. Usually a mailing list.") gflags.DEFINE_string("public_url", "http://www.isi.edu/natural-language/nl-seminar/", "URL to include at bottom of announcements") argv = FLAGS(sys.argv) if FLAGS.website is None or FLAGS.ical is None: sys.stderr.write("SYNTAX: %s --data DATA " "--website WEBSITE --ical ICAL --mailer MAILER" % (argv[0])) sys.exit(1)