A more straightforward solution wanted

jonathon jblake at stamp-coin.com
Fri Sep 24 17:38:26 EDT 1999


	
	I'm bashing my head trying to think of a more straightforward
	way to do the following:

		Read a file.
		Validate that the data in the file is correct.
		If it is correct, add several fields to each record,
			content of the added fields depends upon the
			content in the fields allready present. 

	Here is _one_ short example of what the functions currently
	look like.  It also happens to be one of the more straight
	forward ones.  In most of the others, the values are vastly
	different.  

	Is there a more straightforward method of doing this, other
	than using yet another database, for the lookup functions, etc?
	<< I hesitate to create a database with the data to be added,
	because I'm not sure how many more fields will eventually
	be requested for the database that the output of the script
	currently goes to.  The other question is what to use for the
	lookup database. >> 

	
def vryburg ( record_list ):
   return_list = record_list
   return_list[2] = "Vryburg"
   return_list[30] = 216501
   temp_number = return_list[31]
   scott_number = return_list[6]
   scott_suffix = return_list[7]
   if temp_number == 0 :
       return_list[38] = "regular issues"
       return_list = valid_scott_number_range( return_list, 1, 5)
       return_list[91] = "Cape Of Good Hope"
       return_list[92] = "Vryburg: Boer Occupation"
       return_list = valid_scott_prefix( return_list, "N", "Issued in Vryburg Under Boer Occupation")
       if return_list[26] in [ "sp-", "sp+" ]:
           print "Invalid Scott Number"
       else:
           return_list[50] = "SACC "
           if scott_number = 1:
               return_list[44] = " "
               if scott_suffix = " ":
                   return_list[45] = 1
                   return_list[46] = "Type A"
                   return_list[51] = " "
                   return_list[52] = 1
                   return_list[53] = " "
               elif scott_suffix = "a":
                   return_list[45] = 1
                   return_list[46] = "Type B"
                   return_list[51] = " "
                   return_list[52] = 1
                   return_list[53] = "b"
               else:
                  return_list[45] = 1
                  return_list[46] = "Type A/Italic Z"
                  return_list[51] = " "
                  return_list[52] = 1
                  return_list[53] = "a"
           elif scott_number = 2:
               return_list[44] = " "
               if scott_suffix = " ":
                   return_list[45] = 2
                   return_list[46] = "Type A"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = " "
               elif scott_prefix = "a"
                   return_list[45] = 2
                   return_list[46] = "l for 1"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = "c"
               elif scott_suffix = "b":
                   return_list[45] = 2
                   return_list[46] = "Type B1"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = "b"
               else:
                   return_list[45] = 2
                   return_list[46] = "Type A/Italic Z"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = "a"
           elif scott_number = 3:
               return_list[44] = " "
               if scott_suffix = " ":
                   return_list[45] = 3
                   return_list[46] = "Type B"
                   return_list[51] = " "
                   return_list[52] = 3
                   return_list[53] = " "
               else
                   return_list[45] = 3
                   return_list[46] = "Type B/Italic Z"
                   return_list[51] = " "
                   return_list[52] = 3
                   return_list[53] = "b"
           elif scott_number = 4
               if scott_suffix = " ":
                   return_list[45] = 4
                   return_list[46] = "Type A"
                   return_list[51] = " "
                   return_list[52] = 4
                   return_list[53] = " "
               elif scott_suffix = "a":
                   return_list[45] = 4
                   return_list[46] = "Type B"
                   return_list[51] = " "
                   return_list[52] = 4
                   return_list[53] = "b"
               else
                   return_list[45] = 4
                   return_list[46] = "Type A/Italic Z"
                   return_list[51] = " "
                   return_list[52] = 4
                   return_list[53] = "a"
   elif temp_number == 501 :
       return_list[38] = "Vryburg Occupation Issues"
       return_list = valid_scott_number_range( return_list, 1, 4)
       return_list[91] = "Cape Of Good Hope"
       return_list[92] = "Vryburg: Boer Occupation"
       return_list = valid_scott_prefix( return_list, "N", "Issued in Vryburg Under Boer Occupation")
       if return_list[26] in [ "sp-", "sp+" ]:
           print "Invalid Scott Number"
       else:
           return_list[50] = "SACC "
           if scott_number = 1:
               return_list[44] = " "
               if scott_suffix = " ":
                   return_list[45] = 1
                   return_list[46] = "Type A"
                   return_list[51] = " "
                   return_list[52] = 1
                   return_list[53] = " "
               elif scott_suffix = "a":
                   return_list[45] = 1
                   return_list[46] = "Type B"
                   return_list[51] = " "
                   return_list[52] = 1
                   return_list[53] = "b"
               else:
                  return_list[45] = 1
                  return_list[46] = "Type A/Italic Z"
                  return_list[51] = " "
                  return_list[52] = 1
                  return_list[53] = "a"
           elif scott_number = 2:
               return_list[44] = " "
               if scott_suffix = " ":
                   return_list[45] = 2
                   return_list[46] = "Type A"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = " "
               elif scott_prefix = "a"
                   return_list[45] = 2
                   return_list[46] = "l for 1"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = "c"
               elif scott_suffix = "b":
                   return_list[45] = 2
                   return_list[46] = "Type B1"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = "b"
               else:
                   return_list[45] = 2
                   return_list[46] = "Type A/Italic Z"
                   return_list[51] = " "
                   return_list[52] = 2
                   return_list[53] = "a"
           elif scott_number = 3:
               return_list[44] = " "
               if scott_suffix = " ":
                   return_list[45] = 3
                   return_list[46] = "Type B"
                   return_list[51] = " "
                   return_list[52] = 3
                   return_list[53] = " "
               else
                   return_list[45] = 3
                   return_list[46] = "Type B/Italic Z"
                   return_list[51] = " "
                   return_list[52] = 3
                   return_list[53] = "b"
           elif scott_number = 4
               if scott_suffix = " ":
                   return_list[45] = 4
                   return_list[46] = "Type A"
                   return_list[51] = " "
                   return_list[52] = 4
                   return_list[53] = " "
               elif scott_suffix = "a":
                   return_list[45] = 4
                   return_list[46] = "Type B"
                   return_list[51] = " "
                   return_list[52] = 4
                   return_list[53] = "b"
               else
                   return_list[45] = 4
                   return_list[46] = "Type A/Italic Z"
                   return_list[51] = " "
                   return_list[52] = 4
                   return_list[53] = "a"
           elif scott_number = 5:
               return_list[5]  = "Vryburg: British Occupation"
               return_list[92] = "Vryburg: British Reoccupation"
               return_list[45] = 1
               return_list[46] = " "
               return_list[51] = " "
               return_list[52] = 2
               return_list[53] = "a" 
   else:
       return_list[38] = "Miscellaneous: Other"
       return_list[31] = 999
       return_list[28] = "Sec"
   return return_list

#    This top listing of the tupple is the authoratative one.
#
#    record_list
#    #    This is a list
#    0    This is a null --- i forgot that lists start with zero, not one.
#    1    string_record_id
#    2    temp_country_text : var_country_name
#    3    string_country_number
#    4    string_country_section
#    5    temp_scott_prefix
#    6    string_scott_number
#    7    temp_scott_suffix
#    8    temp_michel_prefix
#    9    string_michel_number
#    10   temp_michel_suffix
#    11   temp_grade : var_grade
#    12   temp_mint_used : var_mint
#    13   string_quantity
#    14   string_price
#    15   temp_description
#    16   temp_certificate
#    17   temp_date
#    18   string_cost
#    19   temp_additional_description
#    20   temp_list_field
#    21   temp_stamp_finder
#    22   temp_photo
#    23   temp_image
#    24   temp_deleted
#    25   temp_del_date
#    26   var_field_list
#    27   date_today
#    the following are for internal program use only
#    28   temp_field_list
#    29   temp_record_id    [ This is slated for elimination ]
#    30   temp_country_number : var_country_number
#    31   temp_country_section : var_country_section : this is a number
#    32   temp_scott_number
#    33   temp_quantity
#    34   temp_price
#    35   temp_cost
#    36   var_graphic_url
#    37   var_html_url
#    38   name_country_section
#    39   ultimate_file_destination
#    40   standard_computer_stamp_number
#    #    Fields between 40 & 70 are for parsing stamp catalog numbers
#    41   Y_T_prefix
#    42   Y_T_number
#    43   Y_T_suffix
#    44   stanley_gibbons_prefix
#    45   stanley_gibbons_number
#    46   stanley_gibbons_suffix
#    47   minkus_prefix
#    48   minukus_number
#    49   minkus_suffix
#    50   specialized_catalog_1_name
#    51   specialized_catalog_1_prefix
#    52   specialized_catalog_1_number
#    53   spcialized_catalog_1_suffix
#    54   specialized_catalog_2_name
#    55   specialized_catalog_2_prefix
#    56   specialized_catalog_2_number
#    57   spcialized_catalog_2_suffix
#    58   specialized_catalog_3_name
#    59   specialized_catalog_3_prefix
#    60   specialized_catalog_3_number
#    61   spcialized_catalog_3_suffix
#    62   specialized_catalog_4_name
#    63   specialized_catalog_4_prefix
#    64   specialized_catalog_4_number
#    65   spcialized_catalog_4_suffix
#    66   specialized_catalog_5_name
#    67   specialized_catalog_5_prefix
#    68   specialized_catalog_5_number
#    69   spcialized_catalog_5_suffix
#    #    The following are for internal file manipulation
#    70   expiration_date          # today's date + 10 days
#    71   read_bad_data_from_here
#    72   the_c_base_is
#    73   the_scratch_file_is
#    74   the_graphic_prefix_is
#    75   the_error_file_is
#    79   the_test_file_is
#    77   number_columns
#    78   " "
#    79   scott_prefix_name
#    80   validate_line
#    The following are background details about the stamp issue
#    81   date_of_issue
#    82   denomination_of_issue
#    83   currency_of_issue
#    84   background_colour
#    85   foreground_color
#    86   watermark
#    87   type_of_printing
#    88   type_of_paper
#    89   luminesence
#    90   specialized_catalog_1_country_name
#    91   specialized_catalog_2_country_name
#    92   specialized_catalog_3_country_name
#    93   specialized_catalog_4_country_name
#    94   specialized_catalog_5_country_name
#    95   stanley_gibbons_country_name
#    96   michel_country_name
#    97   y_t_country_name
#    98   minkus_country_name
#    99   scott_country_name
#   100   topical_category_1
#   101   topical_category_2
#   102   topical_category_3
#   103   topical_category_4
#   104   topical_category_5
#   105   topical_category_6
#   106   topical_category_7
#   107   topical_category_8
#   109   topical_category_9
#   110   topical_category_10






More information about the Python-list mailing list