示例#1
0
 def test_length_validator_creation(self):
     with self.assertRaises(AssertionError):
         Length()
     with self.assertRaises(AssertionError):
         Length(min_length=-2)
     with self.assertRaises(AssertionError):
         Length(max_length=-2)
     with self.assertRaises(AssertionError):
         Length(min_length=-2, max_length=-2)
     with self.assertRaises(AssertionError):
         Length(min_length=6, max_length=3)
示例#2
0
class Song:
	def __init__(self, title, artist, album, length):
		self.__title = title
		self.__artist = artist
		self.__album = album
		self.__length = Length(length)
	
	def __str__(self):
		return f'{self.__artist} - {self.__title} from {self.__album} - {self.__length}'

	def __repr__(self):
		return f'{self.__artist} - {self.__title} from {self.__album} - {self.__length}'

	def __eq__(self, other):
		return self.__title == other.__title and self.__artist == other.__artist \
		and self.__album == other.__album and self.__length == other.__length

	def __hash__(self):
		return hash(self.__title, self.__artist, self.__album, self.__length)

	def length(self, seconds=False, minutes=False, hours=False):
		if seconds==False and minutes==False and hours==False:
			return str(self.__length)
		
		return self.__length.length(seconds, minutes, hours)

	def get_title(self):
		return self.__title	

	def get_artist(self):
		return self.__artist			

	def get_album(self):
		return self.__album	
示例#3
0
    def find_total_length_songs(self):
        time_in_seconds = 0

        for song in self.__songs:
            time_in_seconds += song.length(seconds=True)

        total_len = Length(str(datetime.timedelta(seconds=time_in_seconds)))

        return str(total_len)
示例#4
0
 def convert_unit(self, value, input_unit, output_unit):
     if self.measurement is 'length':
         return Length(value, input_unit, output_unit).convert()
     if self.measurement is 'temperature':
         return Temperature(value, input_unit, output_unit).convert()
     if self.measurement is 'area':
         return Area(value, input_unit, output_unit).convert()
     if self.measurement is 'volume':
         return Volume(value, input_unit, output_unit).convert()
     if self.measurement is 'weight':
         return Weight(value, input_unit, output_unit).convert()
     return "Not a valid measurement is entered! Select from : length, temperature, volume, area, weight"
示例#5
0
	def __init__(self, title, artist, album, length):
		self.__title = title
		self.__artist = artist
		self.__album = album
		self.__length = Length(length)
示例#6
0
        return help


parser = argparse.ArgumentParser(description='inductively coupled PCB memory generator',
                                 formatter_class=CustomFormatter)

parser.add_argument("-w", "--words",      help = "word count (drive lines)", type = int, default = 64)
parser.add_argument("-b", "--bits",       help = "bit count (sense loops)", type = int, default = 64)

parser.add_argument("-u", "--unit",
                    help = "default distance measurement unit",
            	    choices = [str(x) for x in LengthUnit.__members__],
                    default = 'mm')


parser.add_argument("--width",             help = "board width",  type = Length, default = Length('3.9 in'))
parser.add_argument("--length",            help = "board length", type = Length, default = Length('3.9 in'))

parser.add_argument("--trace-width",       help = "trace width", type = Length, default = Length('8.3 mil'))

parser.add_argument("--drive-layer",       help = "drive layer number", type = int, default = 2)
parser.add_argument("--drive-pitch",       help = "drive pitch", type = Length, default = Length('50 mil'))

#parser.add_argument("--coupling-length",   help = "drive-to-sense trace coupling length in mils", type = Length, default = Length('40 mil'))

parser.add_argument("--sense-layer",       help = "sense layer number", type = int, default = 1)
parser.add_argument("--sense-pitch",       help = "sense pitch", type = Length, default = Length('50 mil'))

parser.add_argument("--pad-drill",         help = "pad drill diameter", type = Length, default = Length('42 mil'))

#parser.add_argument("--ground-layer",      help = "ground plane layer number (0 for none)", type = int, default = 15)
示例#7
0
def length_convert():
	length = Length()
	while  True:
		title()
		option = str(input('''
			[1] m a Km
			[2] m a cm
			[3] cm a m
			[4] Km a m
			[5] m a ft
			[6] ft a m
			[7] cm a in
			[8] in a cm
			[9] mi a Km

			[s]alir

			''')).lower()

		if option == '1':
			length.mAKm()
		elif option == '2':
			length.mACm()
		elif option == '3':
			length.cmAM()
		elif option == '4':
			length.kmAM()
		elif option == '5':
			length.mAFt()
		elif option == '6':
			length.ftAM()
		elif option == '7':
			length.cmAIn()
		elif option == '8':
			length.inACm()
		elif option == '9':
			length.miAKm()
		elif option == 's':
			break

		else:
			print('Ingreso de dato no valido')
示例#8
0
from length import Length

len1 = Length(1, 9)
len2 = Length(3, 5)
len3 = len1 + len2
print(len3)
示例#9
0
from length import Length

a = Length(100, "cm")
b = Length(120, "cm")
c = Length(20, "in")

print(a)

# führt intern zum Aufruf von _get_unit
print(a.unit)  # cm

# führt intern zum Aufruf von _set_unit
a.unit = "in"

print(a.value)
print(a.unit)

b = Length.from_string("10cm")
print(b)
print(b.value)
print(b.unit)

print(str(a))  # 39.37in
print(repr(a))  # Length(39.37007874015748, "in")

print(a + c + c)
print(a * 2)  # (__mul__)
print(2 * a)  # (__rmul__)
示例#10
0
class MockFormMin3Max6StopFalse(FlaskForm):
    field = Field(validators=[
        Length(min_length=3, max_length=6, stop=False),
        AlwaysError()
    ])
示例#11
0
class MockFormMin3Max6CustomCallableMessage(FlaskForm):
    field = Field(validators=[
        Length(
            min_length=3, max_length=6, message=lambda: R.string.test_message)
    ])
示例#12
0
class MockFormMin3Max6(FlaskForm):
    field = Field(validators=[Length(min_length=3, max_length=6)])
示例#13
0
class MockFormMinNoneMax6(FlaskForm):
    field = Field(validators=[Length(max_length=6)])
示例#14
0
class MockFormMin3MaxNone(FlaskForm):
    field = Field(validators=[Length(min_length=3)])