Change in pysim[master]: rename card_data to card_key_provider.

laforge gerrit-no-reply at
Tue Apr 6 16:03:29 UTC 2021

laforge has submitted this change. ( )

Change subject: rename card_data to card_key_provider.

rename card_data to card_key_provider.

"data" is an awfully generic term.  Anything stored on a card is data.

This specific code deals with resolving key/pin material from an
external source.

Change-Id: I4c8e1be3e766f7c0565c07b39d48abf8adc375af
R pySim/
2 files changed, 14 insertions(+), 14 deletions(-)

  Jenkins Builder: Verified
  laforge: Looks good to me, approved

diff --git a/ b/
index 931b5ea..d27deb7 100755
--- a/
+++ b/
@@ -48,7 +48,7 @@
 from pySim.ts_31_102 import CardApplicationUSIM
 from pySim.ts_31_103 import CardApplicationISIM
-from pySim.card_data import CardDataCsv, card_data_register, card_data_get_field
+from pySim.card_key_provider import CardKeyProviderCsv, card_key_provider_register, card_key_provider_get_field
 class PysimApp(cmd2.Cmd):
@@ -95,7 +95,7 @@
 			pin_adm = sanitize_pin_adm(arg)
 			# try to find an ADM-PIN if none is specified
-			result = card_data_get_field('ADM1', key='ICCID', value=self.iccid)
+			result = card_key_provider_get_field('ADM1', key='ICCID', value=self.iccid)
 			pin_adm = sanitize_pin_adm(result)
 			if pin_adm:
 				self.poutput("found ADM-PIN '%s' for ICCID '%s'" % (result, self.iccid))
@@ -148,7 +148,7 @@
 		if str(code).upper() not in auto:
 			return sanitize_pin_adm(code)
-		result = card_data_get_field(str(code), key='ICCID', value=self._cmd.iccid)
+		result = card_key_provider_get_field(str(code), key='ICCID', value=self._cmd.iccid)
 		result = sanitize_pin_adm(result)
 		if result:
 			self._cmd.poutput("found %s '%s' for ICCID '%s'" % (code.upper(), result, self._cmd.iccid))
@@ -439,9 +439,9 @@
 	# or from CSV file in home directory
 	csv_default = str(Path.home()) + "/.osmocom/pysim/card_data.csv"
 	if opts.csv:
-		card_data_register(CardDataCsv(opts.csv))
+		card_key_provider_register(CardKeyProviderCsv(opts.csv))
 	if os.path.isfile(csv_default):
-		card_data_register(CardDataCsv(csv_default))
+		card_key_provider_register(CardKeyProviderCsv(csv_default))
 	# If the user supplies an ADM PIN at via commandline args authenticate
 	# immediatley so that the user does not have to use the shell commands
diff --git a/pySim/ b/pySim/
similarity index 86%
rename from pySim/
rename to pySim/
index e35df9e..2e98d7d 100644
--- a/pySim/
+++ b/pySim/
@@ -23,9 +23,9 @@
 import csv
-card_data_provider = [] # type: List[CardData]
+card_key_providers = [] # type: List[CardData]
-class CardData(object):
+class CardKeyProvider(object):
 	VALID_FIELD_NAMES = ['ICCID', 'ADM1', 'IMSI', 'PIN1', 'PIN2', 'PUK1', 'PUK2']
@@ -54,7 +54,7 @@
 		"""get fields from CSV file using a specified key/value pair"""
-class CardDataCsv(CardData):
+class CardKeyProviderCsv(CardKeyProvider):
 	"""card data class that allows the user to query against a specified CSV file"""
 	csv_file = None
 	filename = None
@@ -87,17 +87,17 @@
 		return rc
-def card_data_register(provider:CardData, provider_list=card_data_provider):
+def card_key_provider_register(provider:CardKeyProvider, provider_list=card_key_providers):
 	"""Register a new card data provider"""
-	if not isinstance(provider, CardData):
+	if not isinstance(provider, CardKeyProvider):
 		raise ValueError("provider is not a card data provier")
-def card_data_get(fields, key:str, value:str, provider_list=card_data_provider) -> Dict[str,str]:
+def card_key_provider_get(fields, key:str, value:str, provider_list=card_key_providers) -> Dict[str,str]:
 	"""Query all registered card data providers"""
 	for p in provider_list:
-		if not isinstance(p, CardData):
+		if not isinstance(p, CardKeyProvider):
 			raise ValueError("provider list contains provider, which is not a card data provier")
 		result = p.get(fields, key, value)
 		if result:
@@ -105,10 +105,10 @@
 	return {}
-def card_data_get_field(field:str, key:str, value:str, provider_list=card_data_provider) -> Optional[str]:
+def card_key_provider_get_field(field:str, key:str, value:str, provider_list=card_key_providers) -> Optional[str]:
 	"""Query all registered card data providers for a single field"""
 	for p in provider_list:
-		if not isinstance(p, CardData):
+		if not isinstance(p, CardKeyProvider):
 			raise ValueError("provider list contains provider, which is not a card data provier")
 		result = p.get_field(field, key, value)
 		if result:

To view, visit
To unsubscribe, or for help writing mail filters, visit

Gerrit-Project: pysim
Gerrit-Branch: master
Gerrit-Change-Id: I4c8e1be3e766f7c0565c07b39d48abf8adc375af
Gerrit-Change-Number: 23591
Gerrit-PatchSet: 2
Gerrit-Owner: laforge <laforge at>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <pmaier at>
Gerrit-Reviewer: fixeria <vyanitskiy at>
Gerrit-Reviewer: laforge <laforge at>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the gerrit-log mailing list