mirror of
				https://github.com/KevinMidboe/python-gpiozero.git
				synced 2025-10-29 17:50:37 +00:00 
			
		
		
		
	Clean up repeated string substitutions
This commit is contained in:
		| @@ -228,7 +228,7 @@ class NativePin(LocalPiPin): | ||||
|         self._change_thread = None | ||||
|         self._change_event = Event() | ||||
|         self.function = 'input' | ||||
|         self.pull = 'up' if factory.pi_info.pulled_up('GPIO%d' % number) else 'floating' | ||||
|         self.pull = 'up' if factory.pi_info.pulled_up(self.address[-1]) else 'floating' | ||||
|         self.bounce = None | ||||
|         self.edges = 'both' | ||||
|  | ||||
| @@ -236,7 +236,7 @@ class NativePin(LocalPiPin): | ||||
|         self.frequency = None | ||||
|         self.when_changed = None | ||||
|         self.function = 'input' | ||||
|         self.pull = 'up' if self.factory.pi_info.pulled_up('GPIO%d' % self.number) else 'floating' | ||||
|         self.pull = 'up' if self.factory.pi_info.pulled_up(self.address[-1]) else 'floating' | ||||
|  | ||||
|     def _get_function(self): | ||||
|         return self.GPIO_FUNCTION_NAMES[(self.factory.mem[self._func_offset] >> self._func_shift) & 7] | ||||
| @@ -269,7 +269,7 @@ class NativePin(LocalPiPin): | ||||
|     def _set_pull(self, value): | ||||
|         if self.function != 'input': | ||||
|             raise PinFixedPull('cannot set pull on non-input pin %r' % self) | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up('GPIO%d' % self.number): | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up(self.address[-1]): | ||||
|             raise PinFixedPull('%r has a physical pull-up resistor' % self) | ||||
|         try: | ||||
|             value = self.GPIO_PULL_UPS[value] | ||||
|   | ||||
| @@ -192,14 +192,14 @@ class PiPin(Pin): | ||||
|     """ | ||||
|     def __init__(self, factory, number): | ||||
|         super(PiPin, self).__init__() | ||||
|         self._factory = weakref.proxy(factory) | ||||
|         self._number = number | ||||
|         try: | ||||
|             factory.pi_info.physical_pin('GPIO%d' % number) | ||||
|             factory.pi_info.physical_pin(self.address[-1]) | ||||
|         except PinNoPins: | ||||
|             warnings.warn( | ||||
|                 PinNonPhysical( | ||||
|                     'no physical pins exist for GPIO%d' % number)) | ||||
|         self._factory = weakref.proxy(factory) | ||||
|         self._number = number | ||||
|                     'no physical pins exist for %s' % self.address[-1])) | ||||
|  | ||||
|     @property | ||||
|     def number(self): | ||||
|   | ||||
| @@ -159,7 +159,7 @@ class PiGPIOPin(PiPin): | ||||
|  | ||||
|     def __init__(self, factory, number): | ||||
|         super(PiGPIOPin, self).__init__(factory, number) | ||||
|         self._pull = 'up' if factory.pi_info.pulled_up('GPIO%d' % number) else 'floating' | ||||
|         self._pull = 'up' if factory.pi_info.pulled_up(self.address[-1]) else 'floating' | ||||
|         self._pwm = False | ||||
|         self._bounce = None | ||||
|         self._when_changed = None | ||||
| @@ -177,7 +177,7 @@ class PiGPIOPin(PiPin): | ||||
|             self.frequency = None | ||||
|             self.when_changed = None | ||||
|             self.function = 'input' | ||||
|             self.pull = 'up' if self.factory.pi_info.pulled_up('GPIO%d' % self.number) else 'floating' | ||||
|             self.pull = 'up' if self.factory.pi_info.pulled_up(self.address[-1]) else 'floating' | ||||
|  | ||||
|     def _get_function(self): | ||||
|         return self.GPIO_FUNCTION_NAMES[self.factory.connection.get_mode(self.number)] | ||||
| @@ -219,7 +219,7 @@ class PiGPIOPin(PiPin): | ||||
|     def _set_pull(self, value): | ||||
|         if self.function != 'input': | ||||
|             raise PinFixedPull('cannot set pull on non-input pin %r' % self) | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up('GPIO%d' % self.number): | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up(self.address[-1]): | ||||
|             raise PinFixedPull('%r has a physical pull-up resistor' % self) | ||||
|         try: | ||||
|             self.factory.connection.set_pull_up_down(self.number, self.GPIO_PULL_UPS[value]) | ||||
|   | ||||
| @@ -84,7 +84,7 @@ class RPiGPIOPin(LocalPiPin): | ||||
|  | ||||
|     def __init__(self, factory, number): | ||||
|         super(RPiGPIOPin, self).__init__(factory, number) | ||||
|         self._pull = 'up' if factory.pi_info.pulled_up('GPIO%d' % number) else 'floating' | ||||
|         self._pull = 'up' if factory.pi_info.pulled_up(self.address[-1]) else 'floating' | ||||
|         self._pwm = None | ||||
|         self._frequency = None | ||||
|         self._duty_cycle = None | ||||
| @@ -103,7 +103,7 @@ class RPiGPIOPin(LocalPiPin): | ||||
|         GPIO.setup(self.number, GPIO.OUT, initial=state) | ||||
|  | ||||
|     def input_with_pull(self, pull): | ||||
|         if pull != 'up' and self.factory.pi_info.pulled_up('GPIO%d' % self.number): | ||||
|         if pull != 'up' and self.factory.pi_info.pulled_up(self.address[-1]): | ||||
|             raise PinFixedPull('%r has a physical pull-up resistor' % self) | ||||
|         try: | ||||
|             GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[pull]) | ||||
| @@ -149,7 +149,7 @@ class RPiGPIOPin(LocalPiPin): | ||||
|     def _set_pull(self, value): | ||||
|         if self.function != 'input': | ||||
|             raise PinFixedPull('cannot set pull on non-input pin %r' % self) | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up('GPIO%d' % self.number): | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up(self.address[-1]): | ||||
|             raise PinFixedPull('%r has a physical pull-up resistor' % self) | ||||
|         try: | ||||
|             GPIO.setup(self.number, GPIO.IN, self.GPIO_PULL_UPS[value]) | ||||
|   | ||||
| @@ -79,7 +79,7 @@ class RPIOPin(LocalPiPin): | ||||
|  | ||||
|     def __init__(self, factory, number): | ||||
|         super(RPIOPin, self).__init__(factory, number) | ||||
|         self._pull = 'up' if factory.pi_info.pulled_up('GPIO%d' % number) else 'floating' | ||||
|         self._pull = 'up' if factory.pi_info.pulled_up(self.address[-1]) else 'floating' | ||||
|         self._pwm = False | ||||
|         self._duty_cycle = None | ||||
|         self._bounce = None | ||||
| @@ -138,7 +138,7 @@ class RPIOPin(LocalPiPin): | ||||
|     def _set_pull(self, value): | ||||
|         if self.function != 'input': | ||||
|             raise PinFixedPull('cannot set pull on non-input pin %r' % self) | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up('GPIO%d' % self.number): | ||||
|         if value != 'up' and self.factory.pi_info.pulled_up(self.address[-1]): | ||||
|             raise PinFixedPull('%r has a physical pull-up resistor' % self) | ||||
|         try: | ||||
|             RPIO.setup(self.number, RPIO.IN, self.GPIO_PULL_UPS[value]) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user