예제 #1
0
def existing_bc_set_record(id_input):
    valid_id(id_input)
    if not common.id_exists(bcsr_api, id_input):
        raise argparse.ArgumentTypeError("no BuildConfigurationSetRecord with ID {} exists".format(id_input))
    return id_input
예제 #2
0
 def profile(p):
     if p in list(CREDENTIALS.sections()):
         raise argparse.ArgumentTypeError(f"profile '{p}' already exists")
     return p
예제 #3
0
 def __call__(self, parser, namespace, values, flag_name):
     help = self.help if self.help is not None else ""
     msg = "Flag '%s' is deprecated. %s" % (flag_name, help)
     raise argparse.ArgumentTypeError(msg)
예제 #4
0
파일: fa2wgs.py 프로젝트: zorrodong/PSiTE
def check_file(f=None):
    if not os.path.isfile(f):
        raise argparse.ArgumentTypeError("'{}' doesn't exist or isn't a file.".format(f))
    return f
    division = 4
    for i in range(len(dy_bpm)):
        start, next_t, bpm, start_t = dy_bpm[i]
        start_t = 1000 * float(start_t)
        next_t = 1000 * float(next_t)
        bpm = float(bpm)
        simu_t = start_t
        # delt means the insterval between two immediate mis, use millisecond
        delt = 1000 / (division * (bpm / 60)) 
        while (simu_t < next_t):
            # mis has the structure of [(sequence, time), (sequence, time), ...]
            mis_result.append([count, simu_t])               
            simu_t += delt
            count += 1
    return mis_result

if __name__ == "__main__":
    if len(sys.argv) != 2:
        print( "usage: inputfile outputfile")
        raise argparse.ArgumentTypeError('the number of argument has to be 2')
        exit(-1)

    with open(sys.argv[1], 'r') as my_file:
        csvreader = csv.reader(my_file)
        dy_bpm = list(csvreader)

    mis_result = getMIS(dy_bpm)

    #output the mis for saving
    writer = csv.writer(sys.stdout)
    writer.writerows(mis_result)
예제 #6
0
파일: sim.py 프로젝트: hbrobin/trex-core
def unsigned_int(x):
    x = int(x)
    if x < 0:
        raise argparse.ArgumentTypeError("argument must be >= 0")

    return x
예제 #7
0
 def directory(path: str) -> Path:
     selection = Path(path)
     if not selection.is_dir():
         raise argparse.ArgumentTypeError(f"{selection} must be a directory")
     return selection
예제 #8
0
def valid_url(urlInput):
    if not validators.url(urlInput):
        raise argparse.ArgumentTypeError("invalid url")
    return urlInput
예제 #9
0
def valid_bc_name(name_input):
    pattern = re.compile(bc_name_regex)
    if not pattern.match(name_input):
        raise argparse.ArgumentTypeError("name contains invalid characters")
    return name_input
예제 #10
0
def valid_date(dateInput):
    try:
        dateInput = get_localzone().localize(datetime.datetime.strptime(dateInput, '%Y-%m-%d'))
    except ValueError:
        raise argparse.ArgumentTypeError("Date format: yyyy-mm-dd")
    return dateInput
예제 #11
0
def valid_id(id_input):
    if not id_input.isdigit():
        raise argparse.ArgumentTypeError("an ID must be a positive integer")
    return id_input
예제 #12
0
def existing_running_build(id_input):
    valid_id(id_input)
    if not common.id_exists(running_api, id_input):
        raise argparse.ArgumentTypeError("no RunningBuild with ID {} exists".format(id_input))
    return id_input
예제 #13
0
def existing_license(id_input):
    valid_id(id_input)
    if not common.id_exists(licenses_api, id_input):
        raise argparse.ArgumentTypeError("no License with ID {} exists".format(id_input))
    return id_input
예제 #14
0
def existing_build_record(id_input):
    valid_id(id_input)
    if not common.id_exists(records_api, id_input):
        raise argparse.ArgumentTypeError("no BuildRecord with ID {} exists".format(id_input))
    return id_input
예제 #15
0
파일: wacker.py 프로젝트: swagkarna/wacker
def check_interface(interface):
    if not os.path.isdir(f'/sys/class/net/{interface}/wireless/'):
        raise argparse.ArgumentTypeError(f'{interface} is not a wireless adapter')
    return interface
예제 #16
0
def unique_bc_name(name_input):
    if common.get_id_by_name(configs_api, name_input):
        raise argparse.ArgumentTypeError("BuildConfiguration name '{}' is already in use".format(name_input))
    return name_input
예제 #17
0
파일: sim.py 프로젝트: hbrobin/trex-core
def is_valid_file(filename):
    if not os.path.isfile(filename):
        raise argparse.ArgumentTypeError("The file '%s' does not exist" %
                                         filename)

    return filename
예제 #18
0
def existing_bc_name(name_input):
    valid_bc_name(name_input)
    if not common.get_id_by_name(configs_api, name_input):
        raise argparse.ArgumentTypeError("no BuildConfiguration with the name {} exists".format(name_input))
    return name_input
예제 #19
0
def float_(inp):
    try:
        return float(inp)
    except:
        raise argparse.ArgumentTypeError('Unsupported value encountered.')
예제 #20
0
def existing_bc_id(id_input):
    valid_id(id_input)
    if not common.id_exists(configs_api, id_input):
        raise argparse.ArgumentTypeError("no BuildConfiguration with ID {} exists".format(id_input))
    return id_input
예제 #21
0
파일: fa2wgs.py 프로젝트: zorrodong/PSiTE
def check_folder(directory=None):
    if not os.path.isdir(directory):
        raise argparse.ArgumentTypeError("'{}' doesn't exist or isn't a folder.".format(directory))
    return directory
예제 #22
0
def existing_product_id(id_input):
    valid_id(id_input)
    if not common.id_exists(products_api, id_input):
        raise argparse.ArgumentTypeError("no Product with ID {} exists".format(id_input))
    return id_input
예제 #23
0
파일: fa2wgs.py 프로젝트: zorrodong/PSiTE
def check_depth(value=None):
    fvalue=float(value)
    if fvalue<0:
        raise argparse.ArgumentTypeError("{} is an invalid value for read depth.".format(value)+
            "It should be a non-negative float number.")
    return fvalue
예제 #24
0
def existing_product_name(name_input):
    if not common.get_id_by_name(products_api, name_input):
        raise argparse.ArgumentTypeError("no Product with the name {} exists".format(name_input))
    return name_input
def valid_date(s):
    try:
        return datetime.strptime(s, "%Y-%m-%d")
    except ValueError:
        msg = "Not a valid date: '{0}'.".format(s)
        raise argparse.ArgumentTypeError(msg)
예제 #26
0
def positive_nonzero_int(val):
    ival = positive_int(val)
    if ival == 0:
        raise argparse.ArgumentTypeError("must be nonzero")
    return ival
예제 #27
0
def mkdate(datestr):
    try:
        fulltime = time.strptime(datestr, '%Y-%m-%d')
        return datetime.date(fulltime.tm_year, fulltime.tm_mon, fulltime.tm_mday)
    except ValueError:
        raise argparse.ArgumentTypeError(datestr + ' is not a proper date string')
예제 #28
0
파일: wacker.py 프로젝트: swagkarna/wacker
def check_bssid(mac):
    if not re.match(r'^([0-9a-fA-F]{2}(?::[0-9a-fA-F]{2}){5})$', mac):
        raise argparse.ArgumentTypeError(f'{mac} is not a valid bssid')
    return mac
예제 #29
0
 def check_value_range(value):
     forced_int_value = int(value)
     if forced_int_value < 0 or forced_int_value > 100:
         raise argparse.ArgumentTypeError('{} is not a value between 0 and 100'.format(value))
     return forced_int_value
예제 #30
0
def unique_project_name(name_input):
    if common.get_id_by_name(projects_api, name_input):
        raise argparse.ArgumentTypeError("a Project with name {} already exists".format(name_input))
    return name_input