Want more features on Pastebin? Sign Up, it's FREE!
Guest

Phone Numbers Generator v1.3

By: openSsme on Oct 7th, 2012  |  syntax: Python  |  size: 4.71 KB  |  views: 287  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. # Python 3.2.3
  2. #
  3. #  PNG-V1.3.py
  4. #  
  5. #  Copyright 2012 openSsme <openSsme@gmail.com>
  6. #  
  7. #  This program is free software; you can redistribute it and/or modify
  8. #  it under the terms of the GNU General Public License as published by
  9. #  the Free Software Foundation; either version 2 of the License, or
  10. #  (at your option) any later version.
  11. #  
  12. #  This program is distributed in the hope that it will be useful,
  13. #  but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. #  GNU General Public License for more details.
  16. #  
  17. #  You should have received a copy of the GNU General Public License
  18. #  along with this program; if not, write to the Free Software
  19. #  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  20. #  MA 02110-1301, USA.
  21. #  
  22.  
  23.  
  24. import sys, time, mmap, os
  25.  
  26. os.system("mode con cols=90 lines=40")
  27.  
  28.  
  29. def banner():
  30.  
  31.         print ('\n\n\n'
  32.         "-----------------------------------------------------------------------------------------\n"
  33.         "=========================================================================================\n\n"
  34.         ""
  35.         "                           NUMBERS GENERATOR V1.3 10/2012 BY openSsme                   \n\n"
  36.         ""
  37.         "=========================================================================================\n"
  38.         "-----------------------------------------------------------------------------------------")
  39.  
  40.  
  41. def clear():
  42.        
  43.         os.system('cls' if os.name == 'nt' else 'clear')
  44.         return ''
  45.  
  46.  
  47. def main():
  48.  
  49.         usrInput = input ("\n\n\n\n     Select an option:\n\n"
  50.         ""
  51.         "               1) Generate customized numbers\n"
  52.         "               2) Generate mobile numbers (israel)\n"
  53.         "               3) Generate landline numbers (israel)\n"
  54.         "               4) Quit properly\n\n\n\n\n")
  55.  
  56.  
  57.  
  58.         if usrInput == "1":
  59.  
  60.                 clear()
  61.  
  62.                 f = open ( input ('\n\n\n' + "Enter filename for generated numbers:  ") + ".txt" , 'w')
  63.                 prefix = input ('\n' + "Enter a prefix number:  ")
  64.                 number = int ( input ('\n' + "Enter the first number to generate from:  ") )
  65.                 limit = int ( input ('\n' + "Enter the last number to generate:  ") )
  66.  
  67.                 if number >= 1000000:
  68.  
  69.                         print ("\n\n\n\n\n\nGenerating. might take a few seconds for a 7+ digits numbers..")
  70.                 else:
  71.                         print ("\n\n\n\n\n\nGenerating...")
  72.  
  73.                 if number <= limit:
  74.                         # GENERATOR
  75.                         while number != limit:
  76.                                        
  77.                                 number = number+1
  78.                                 f.write(str(prefix)+str(number)+'\n')
  79.                         # END OF GENERATOR
  80.                                
  81.                 else:
  82.                         print ("\n\nFirst number must be smaller or equal to last number.\n\n")
  83.                         time.sleep(3)
  84.                         clear()
  85.                         main()
  86.  
  87.                 # COUNTER
  88.                 f = open(f.name, "r+")
  89.                 buf = mmap.mmap(f.fileno(), 0)
  90.                 lines = 0
  91.                 readline = buf.readline
  92.                 while readline():
  93.                         lines += 1
  94.  
  95.                 print ("\nDone generating list of numbers prefixed with '" +prefix+ "'" "\n\n           Counted " +str(lines)+ " lines.\n\n\n\n")
  96.                 # END OF COUNTER
  97.  
  98.                 time.sleep(3)
  99.                 clear()
  100.                 main()
  101.  
  102.  
  103.  
  104.  
  105.  
  106.         if usrInput == "2":
  107.  
  108.                 clear()
  109.  
  110.                 f = open ( input ("\n\n\nEnter filename for generated phone numbers:  ") + ".txt" , 'w')
  111.                 prefix = input ("\nEnter carrier prefix number (050, 052, 053, 054, 057):  ")
  112.                 number = 1000000
  113.  
  114.                 print ("\n\n\n\n\n\nGenerating. might take a few seconds..\n\n\n\n")
  115.  
  116.                 # GENERATOR
  117.                 while number != 9999999:
  118.  
  119.                         number = number+1
  120.                         f.write(str(prefix)+str(number)+'\n')
  121.                 # END OF GENERATOR
  122.  
  123.                 # COUNTER
  124.                 f = open(f.name, "r+")
  125.                 buf = mmap.mmap(f.fileno(), 0)
  126.                 lines = 0
  127.                 readline = buf.readline
  128.                 while readline():
  129.                         lines += 1
  130.  
  131.                 print ("\nDone generating list of numbers prefixed with '" +prefix+ "'" "\n\n           Counted " +str(lines)+ " lines.\n\n\n\n")
  132.                 # END OF COUNTER
  133.  
  134.                 time.sleep(3)
  135.                 clear()
  136.                 main()
  137.  
  138.  
  139.  
  140.  
  141.         if usrInput == "3":
  142.  
  143.                 clear()
  144.  
  145.                 f = open ( input ('\n\n\n' + "Enter filename for generated phone numbers:  ") + ".txt" , 'w')
  146.                 prefix = input ('\n' + "Enter area code (02, 03, 04, 077, 08, 09):  ")
  147.                 number = 5000000
  148.  
  149.  
  150.                 print ("\n\n\n\n\n\nGenerating. might take a few seconds..\n\n\n\n")
  151.  
  152.                 # GENERATOR
  153.                 while number != 9999999:
  154.  
  155.                         number = number+1
  156.                         f.write(str(prefix)+str(number)+'\n')
  157.                 # END OF GENERATOR
  158.  
  159.                 # COUNTER
  160.                 f = open(f.name, "r+")
  161.                 buf = mmap.mmap(f.fileno(), 0)
  162.                 lines = 0
  163.                 readline = buf.readline
  164.                 while readline():
  165.                         lines += 1
  166.  
  167.                 print ("\nDone generating list of numbers prefixed with '" +prefix+ "'" "\n\n           Counted " +str(lines)+ " lines.\n\n\n\n")
  168.                 # END OF COUNTER
  169.  
  170.                 time.sleep(3)
  171.                 clear()
  172.                 main()
  173.  
  174.        
  175.  
  176.         if usrInput == "4":
  177.  
  178.                 clear()
  179.                
  180.                 print ("\n\n\nQuitting.\n\n\n\n\n")
  181.                 time.sleep(0.5)
  182.                 sys.exit()
  183.  
  184.  
  185.         else:
  186.                 print ("\n\n\nNo such thing.\n\n\n\n\n\n\n\n")
  187.                 time.sleep(2)
  188.                 clear()
  189.                 main()
  190.  
  191.        
  192. #~~~~~~~~~~ MAIN PROGRAM !!! ~~~~~~~~~#
  193. #~~~~~~~~~ ONLY TWO LINES !!! ~~~~~~~~#
  194. banner()
  195. main()
clone this paste RAW Paste Data