def arg_ax_logx(self, parser): """X-axis is called X and defaults to logarithmic """ self.xaxis_type = 'logx' parser.add_argument('--nologx', action='store_true', help='make X-axis linear, default=logarithmic') self.arg_ax_x(parser)
def get(self): parser = RequestParser() parser.add_argument('token', type=str) args = parser.parse_args() if UserService.check_token(args['token']): return {'message': 'success'} return {'message': 'error'}
def arg_ax_liny(self, parser): """Y-axis is called Y and defaults to linear """ self.yaxis_type = 'liny' parser.add_argument('--logy', action='store_true', help='make Y-axis logarithmic, default=linear') self.arg_ax_y(parser)
def arg_ax_logy(self, parser): """Y-axis is called Y and defaults to log """ self.yaxis_type = 'logy' parser.add_argument('--nology', action='store_true', help='make Y-axis linear, default=logarthmic') self.arg_ax_y(parser)
def arg_datasoure(self, parser): parser.add_argument('-c', '--framecache', help='use .gwf files in cache not NDS2,' + ' default use NDS2') parser.add_argument('-n', '--nds2-server', metavar='HOSTNAME', help='name of nds2 server to use, default is to ' 'try all of them')
def arg_ax_intlin(self, parser): """Intensity (colors) default to linear """ self.iaxis = 'lini' parser.add_argument('--logcolors', action='store_true', help='set intensity scale of image ' 'to logarithmic, default=linear') self.arg_ax_int(parser)
def arg_ax_intlog(self, parser): """Intensity (colors) default to log """ self.iaxis = "logi" parser.add_argument('--lincolors', action='store_true', help='set intensity scale of image to linear, ' 'default=logarithmic') self.arg_ax_int(parser)
def arg_ax_y(self, parser): """Y-axis limits. Do not call this one use arg_ax_liny or arg_ax_logy """ parser.add_argument('--ymin', help='fix min value for yaxis' ' defaults to min of data') parser.add_argument('--ymax', help='max value for y-axis ' 'default to max of data')
def arg_chan1(self, parser): # list of channel names when only 1 is required parser.add_argument('--chan', nargs='+', action='append', required=True, help='One or more channel names.') self.arg_chan(parser)
def arg_freq2(self, parser): """Parameters for FFT based plots, with Coherencegram defaults """ self.is_freq_plot = True parser.add_argument('--secpfft', default='0.5', help='length of fft in seconds ' 'for each calculation, default=0.5') parser.add_argument('--overlap', default='0.9', help='Overlap as fraction [0-1), default=0.9')
def arg_ax_linx(self, parser): """X-axis is called X and defaults to linear """ self.xaxis_type = 'linx' parser.add_argument('--logx', action='store_true', help='make X-axis logarithmic, default=linear') parser.add_argument('--epoch', help='center X axis on this GPS time. ' 'Incompatible with logx') self.arg_ax_x(parser)
def post(self): parser = RequestParser() parser.add_argument('email', type=str) parser.add_argument('password', type=str) args = parser.parse_args() salted_string = (args['password'] + SALT) hashed_pwd = hash_sha(salted_string) if user_service.check_login(args['email'], hashed_pwd): return {'message': 'ok', 'token': user_service.get_token(args['email'], hashed_pwd)} else: return {'message': 'error'}
def arg_chan2(self, parser): """list of channel names when at least 2 are required """ parser.add_argument('--chan', nargs='+', action='append', required=True, help='Two or more channels or times, first ' 'one is compared to all the others') parser.add_argument('--ref', help='Reference channel against which ' 'others will be compared') self.arg_chan(parser)
def post(self): parser = RequestParser() parser.add_argument('email', type=str) parser.add_argument('password', type=str) args = parser.parse_args() salted_string = (args['password'] + SALT) hashed_pwd = hash_sha(salted_string) if user_service.check_login(args['email'], hashed_pwd): return { 'message': 'ok', 'token': user_service.get_token(args['email'], hashed_pwd) } else: return {'message': 'error'}
def post(self): try: parser = RequestParser() parser.add_argument('email', type=str) parser.add_argument('token', type=str) args = parser.parse_args() pwd = ''.join(choice(ascii_uppercase) for i in range(8)) salted_string = (pwd + SALT) hashed_pwd = hash_sha(salted_string) UserService.create_user(args['email'], hashed_pwd, args['token']) send_mail(args['email'], "Account information", "Hi, This is your temporary password for your account: " + pwd) return {'message': 'ok'} except: return {'message': 'error'}
def post(self): try: parser = RequestParser() parser.add_argument('email', type=str) parser.add_argument('token', type=str) args = parser.parse_args() pwd = ''.join(choice(ascii_uppercase) for i in range(8)) salted_string = (pwd + SALT) hashed_pwd = hash_sha(salted_string) UserService.create_user(args['email'], hashed_pwd, args['token']) send_mail( args['email'], "Account information", "Hi, This is your temporary password for your account: " + pwd) return {'message': 'ok'} except: return {'message': 'error'}
def arg_ax_lf(self, parser): """One of this axis is frequency and logarthmic """ parser.add_argument('--nologf', action='store_true', help='make frequency axis linear, ' 'default=logarithmic') parser.add_argument('--fmin', help='min value for frequency axis') parser.add_argument('--fmax', help='max value for frequency axis')
def arg_chan(self, parser): """Allow user to specify list of channel names, list of start gps times and single duration """ parser.add_argument('--start', nargs='+', help='Starting GPS times(required)') parser.add_argument('--duration', default=10, help='Duration (seconds) [10]') self.arg_datasoure(parser) parser.add_argument('--highpass', help='frequency for high pass filter, ' 'default no filter') parser.add_argument('--lowpass', help='frequency for low pass filter, ' 'default no filter')
def arg_imag(self, parser): """Add arguments for image based plots like spectrograms """ parser.add_argument('--nopct', action='store_true', help='up and lo are pixel values, ' 'default=percentile if not normalized') parser.add_argument('--nocolorbar', action='store_true', help='hide the color bar') parser.add_argument('--norm', action='store_true', help='Display the ratio of each fequency ' 'bin to the mean of that frequency')
def arg_ax_int(self, parser): """Images have an intensity axis """ parser.add_argument('--imin', help='min pixel value in resulting image') parser.add_argument('--imax', help='max pixek value in resulting image') parser.add_argument('--cmap', default=DEFAULT_CMAP, help='Colormap. See ' 'https://matplotlib.org/examples/color/' 'colormaps_reference.html for options')
if issued and issued != 'None': data['issued'] = issued data['category'] = get_value(ebook_json['type']) data['downloads'] = ebook_json.get('downloads', '0') data['languages'] = get_values(ebook_json['language']) data['subjects'] = get_values(ebook_json.get('subject', [])) data['bookshelves'] = get_values(ebook_json.get('bookshelf', [])) agents = ebook_json.get('creator', []) data['authors'] = get_list(agents) # map from attrs to uri attrs_to_uri = get_attrs_to_uri(get_uri_to_attrs(rdf_path)) data['files'] = [ normalize_file_json(obj['file'], attrs_to_uri) for obj in get_list(ebook_json.get('hasFormat', [])) if obj != None ] return data if __name__ == '__main__': import argparse parser = argparse.ArgumentParser(description='Parse Gutenberg RDF file') parser.add_argument('path', help='Path to a rdf file') args = parser.parse_args() print_json(rdf2json(args.path))
def post(self): parser = RequestParser() parser.add_argument('email', type=str) parser.add_argument('password', type=str) parser.add_argument('re_password', type=str) parser.add_argument('phone', type=str) parser.add_argument('address', type=str) parser.add_argument('description', type=str)
def post(self): parser = RequestParser() parser.add_argument('file', type=werkzeug.datastructures.FileStorage) parser.add_argument('name', type=str) parser.add_argument('price', type=str) parser.add_argument('description', type=str) parser.add_argument('type', type=int) parser.add_argument('token', type=str) args = parser.parse_args() if UserService.check_token(args['token']): if args['type'] == 0: return {'message': 'success'} ImageService.save_2d_image(args) else: ImageService.save_3d_image(args) return {'message': 'success'} return {'message': 'error'}, 403
def add_arguments(self,parser): parser.add_argument('path', type=str)
def arg_plot(self, parser): """Add arguments common to all plots """ parser.add_argument('-g', '--geometry', default='1200x600', help='size of resulting image WxH, ' 'default: %(default)s') parser.add_argument('--interactive', action='store_true', help='when running from ipython ' 'allows experimentation') parser.add_argument('--title', action='append', help='One or more title lines') parser.add_argument('--suptitle', help='1st title line (larger than the others)') parser.add_argument('--xlabel', help='x axis text') parser.add_argument('--ylabel', help='y axis text') parser.add_argument('--out', help='output filename, type=ext (png, pdf, ' 'jpg), default=gwpy.png') # legends match input files in position are displayed if specified. parser.add_argument('--legend', nargs='*', action='append', help='strings to match data files') parser.add_argument('--nolegend', action='store_true', help='do not display legend') parser.add_argument('--nogrid', action='store_true', help='do not display grid lines') # allow custom styling with a style file parser.add_argument( '--style', metavar='FILE', help='path to custom matplotlib style sheet, see ' 'http://matplotlib.org/users/style_sheets.html#style-sheets ' 'for details of how to write one')
def arg_ax_x(self, parser): """X-axis is called X. Do not call this one call arg_ax_linx or arg_ax_logx """ parser.add_argument('--xmin', help='min value for X-axis') parser.add_argument('--xmax', help='max value for X-axis')
def arg_qxform(self, parser): """Q transform is a bit different""" parser.add_argument('--chan', required=True, help='Channel name.') parser.add_argument('--gps', required=True, help='Event time (float)') parser.add_argument('--outdir', required=True, help='Directory for output images') parser.add_argument('--search', help='Seconds analyzed', default='64') parser.add_argument('--sample_freq', help='Downsample freq', default=2048) parser.add_argument('--plot', nargs='*', help='One or more times to plot') parser.add_argument('--frange', nargs=2, help='Frequency ' + 'range to plot') parser.add_argument('--erange', nargs=2, help='Normalized ' + 'energy range') parser.add_argument('--srange', nargs=2, help='Search ' + 'frequency range') parser.add_argument('--qrange', nargs=2, help='Search Q ' + 'range') parser.add_argument('--nowhiten', action='store_true', help='do not whiten input ' + 'before transform') self.arg_datasoure(parser)
def parse(self) -> Namespace: parser = argparse.ArgumentParser() parser.add_argument("--estimate", "-e", type=int) parser.add_argument("--due", "-d", choices=["day", "week", "sprint", "month", "year"]) parser.add_argument("--priority", "-p", type=int) parser.add_argument("--read", "-r", action="store_true") parser.add_argument("--sprint-length", "-sl", type=int) parser.add_argument("--sprint-points", "-sp", type=int) parser.add_argument("--init", action="store_true") parser.add_argument("--next", action="store_true") parser.add_argument("--verbose", "-v", action="store_true") parser.add_argument("name", nargs="+" if self.is_name_required() else "*") args = parser.parse_args() return args
import pandas as pd import numpy as np from dateutil.parser import parser from sqlalchemy import create_engine from etlfuncs import test_categories, get_cat_values import argparse if __name__ == '__main__': parser = argparse.ArgumentParser( prog='Disaster Response ETL Pipeline', formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument('--messages_path', type=str, default='./raw_data/messages.csv', help=""" Path to the messages csv dataset""") parser.add_argument('--categories_path', type=str, default='./raw_data/categories.csv', help=""" Path to the categories csv dataset""") parser.add_argument('--sql_db_path', type=str, default='/database/disaster_response.db', help=""" Path to the SQLite database to save the results into""") parser.add_argument('--sql_table', type=str, default='categorized_messages',
# Return to Original Directory os.chdir(owd) #topic_modeler("tfidf_std", "lda", 15, 10, [1,4], 5000) if __name__=="__main__": parser = argparse.ArgumentParser(description='Prepare input file', formatter_class=argparse.RawTextHelpFormatter) parser.add_argument('vectorizer_type', type=str, help=textwrap.dedent("""\ Select the desired vectorizer for either text or tweet @ tfidf_std | TFIDF Vectorizer (for tweets) @ tfidf_custom | TFIDF Vectorizer with Custom Tokenizer (for tweets) """ )) parser.add_argument('topic_modlr', type=str, help=textwrap.dedent("""\ Select the desired topic model classifier (clf) @ lda | Topic Model: LatentDirichletAllocation (LDA) @ nmf | Topic Model: Non-Negative Matrix Factorization (NMF) @ pca | Topic Model: Principal Components Analysis (PCA) """ )) # parser.add_argument('search_query', type=str, # help=textwrap.dedent("""\ # Specify the word you need to search