From 4c9e14b7043e93d8ae33a510e529a681daa497cc Mon Sep 17 00:00:00 2001 From: Emil Merle <49149679+emilmerle@users.noreply.github.com> Date: Mon, 7 Sep 2020 18:38:40 +0200 Subject: [PATCH 01/27] Create README.md --- README.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..1c0cb9b --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# FindingThingsWithPython +Small and easy scripts to find things in texts with python. +Feel free to contribute but please keep things easy to understand. From 6fc3b865beec611a650b6d40471b4a48f7fbc867 Mon Sep 17 00:00:00 2001 From: Emil Merle Date: Tue, 8 Sep 2020 19:37:52 +0200 Subject: [PATCH 02/27] Added numberInFile.py --- ...berOnClipboard.py => numberInClipboard.py} | 10 ++- phoneNumbers/numberInFile.py | 69 +++++++++++++++++++ 2 files changed, 73 insertions(+), 6 deletions(-) rename phoneNumbers/{numberOnClipboard.py => numberInClipboard.py} (82%) create mode 100644 phoneNumbers/numberInFile.py diff --git a/phoneNumbers/numberOnClipboard.py b/phoneNumbers/numberInClipboard.py similarity index 82% rename from phoneNumbers/numberOnClipboard.py rename to phoneNumbers/numberInClipboard.py index da6fcb2..8030adb 100644 --- a/phoneNumbers/numberOnClipboard.py +++ b/phoneNumbers/numberInClipboard.py @@ -1,5 +1,5 @@ #! python3 -# numberOnClipboard.py - Finds phone numbers on the clipboard and copies them to the clipboard +# numberInClipboard.py - Finds phone numbers on the clipboard and copies them to the clipboard # Usage: call the program with a country as the first argument # Example: >>> numberOnClipboard.py germany @@ -23,15 +23,13 @@ try: argumentOne = sys.argv[1] except IndexError: - print("No argument given. Try again with a country as an argument") - exit() + exit("No argument given. Try again with a country as an argument") if(argumentOne in countryDict): #Create regex object regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE) else: - print("No number format for that country found") - exit() + exit("No number format for that country found") @@ -44,7 +42,7 @@ if len(matches) > 0: pyperclip.copy(' -+- '.join(matches)) - print("Phone numbers found:") + print("Phone number(s) found:") print('\n'.join(matches)) else: print('No phone numbers or email addresses found.') diff --git a/phoneNumbers/numberInFile.py b/phoneNumbers/numberInFile.py new file mode 100644 index 0000000..f097f97 --- /dev/null +++ b/phoneNumbers/numberInFile.py @@ -0,0 +1,69 @@ +#! python3 +# numberInFile.py - Finds phone numbers in a given file and copies them to the clipboard +# Usage: call the program with a country as the first argument and the location of the file as the second argument +# Example: >>> numberInFile.py germany C:\\Users\\ExampleUser\\Documents\\phoneNumbers.txt + +import pyperclip, re, sys, os + +#Create dictionary to store regex expressions for different countries +countryDict = {} + +#Create phone regex for country specific number format and add it to countryDict + +germany = r'''( + (\d{3}|\(\d{3}\))? # area code (optional) + (\s|-|\.|/)? # separator (optional) + (\d{7,9}) # 7 to 9 digits + )''' +countryDict["germany"] = germany + +# Check if sys.argv[1] is given and in countryDict +argumentOne = "" +try: + argumentOne = sys.argv[1] +except IndexError: + exit("No argument given. Try again with a country as an argument") + +if(argumentOne in countryDict): + #Create regex object + regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE) +else: + exit("No number format for that country found") + +#Check if sys.argv[2] is given +argumentTwo = "" +try: + argumentTwo = sys.argv[2] +except IndexError: + exit("No second argument given. Try again with a file path as an argument") + + +# Make absolute path if given path is a relative path +if(not os.path.isabs(argumentTwo)): + argumentTwo = os.path.abspath(argumentTwo) + +openedContent = "" + +# Check if argumentTwo is a valid path and file +if(os.path.exists(argumentTwo) and os.path.isfile(argumentTwo)): + # Try to open and read file + try: + openedFile = open(argumentTwo, "r") + openedContent = openedFile.read() + except OSError: + exit("Could not open file") +else: + exit("Given file does not exist: " + argumentTwo) + +matches = [] +#Find all phone numbers and store them in matches +for groups in regexCompile.findall(openedContent): + phoneNumber = groups[0] + matches.append(phoneNumber) + +if len(matches) > 0: + pyperclip.copy(' -+- '.join(matches)) + print("Phone number(s) found:") + print('\n'.join(matches)) +else: + print('No phone numbers or email addresses found.') \ No newline at end of file From 9a0d098a1bb329381c6d828bbf7fcbc161c62a22 Mon Sep 17 00:00:00 2001 From: Emil Merle Date: Tue, 8 Sep 2020 19:59:00 +0200 Subject: [PATCH 03/27] Added emailAdresses/emailInClipboard.py --- emailAdresses/emailInClipboard.py | 28 ++++++++++++++++++++++++++++ phoneNumbers/numberInClipboard.py | 2 +- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 emailAdresses/emailInClipboard.py diff --git a/emailAdresses/emailInClipboard.py b/emailAdresses/emailInClipboard.py new file mode 100644 index 0000000..3e0b6a4 --- /dev/null +++ b/emailAdresses/emailInClipboard.py @@ -0,0 +1,28 @@ +#! python3 +# emailInClipboard.py - Finds email addresses on the clipboard and copies them to the clipboard +# Usage: call the program +# Example: >>> numberOnClipboard.py + +import pyperclip, re, sys + +# Create email regex. +emailRegex = re.compile(r'''( + [a-zA-Z0-9._%+-]+ # username + @ # @ symbol + [a-zA-Z0-9.-]+ # domain name + (\.[a-zA-Z]{2,4}) # dot-something + )''', re.VERBOSE) + +# Find matches in clipboard text. +text = str(pyperclip.paste()) +matches = [] +for groups in emailRegex.findall(text): + emails = groups[0] + matches.append(emails) + +if len(matches) > 0: + pyperclip.copy(' -+- '.join(matches)) + print("Email address(es) found:") + print('\n'.join(matches)) +else: + print('No email addresses found.') diff --git a/phoneNumbers/numberInClipboard.py b/phoneNumbers/numberInClipboard.py index 8030adb..9fff001 100644 --- a/phoneNumbers/numberInClipboard.py +++ b/phoneNumbers/numberInClipboard.py @@ -45,4 +45,4 @@ print("Phone number(s) found:") print('\n'.join(matches)) else: - print('No phone numbers or email addresses found.') + print('No phone numbers found.') From c9f9003fb11c9981740f304bae3d90599e47d543 Mon Sep 17 00:00:00 2001 From: Emil Merle Date: Tue, 8 Sep 2020 20:02:32 +0200 Subject: [PATCH 04/27] Fixed some typos --- emailAdresses/emailInClipboard.py | 2 +- phoneNumbers/numberInClipboard.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/emailAdresses/emailInClipboard.py b/emailAdresses/emailInClipboard.py index 3e0b6a4..027390b 100644 --- a/emailAdresses/emailInClipboard.py +++ b/emailAdresses/emailInClipboard.py @@ -25,4 +25,4 @@ print("Email address(es) found:") print('\n'.join(matches)) else: - print('No email addresses found.') + print('No email address found.') diff --git a/phoneNumbers/numberInClipboard.py b/phoneNumbers/numberInClipboard.py index 9fff001..d631c41 100644 --- a/phoneNumbers/numberInClipboard.py +++ b/phoneNumbers/numberInClipboard.py @@ -45,4 +45,4 @@ print("Phone number(s) found:") print('\n'.join(matches)) else: - print('No phone numbers found.') + print('No phone number found.') From d5f9658d36490ea51890f6f05b217383f43df2fc Mon Sep 17 00:00:00 2001 From: Emil Merle Date: Tue, 8 Sep 2020 20:12:39 +0200 Subject: [PATCH 05/27] Added emailInFile.py --- emailAdresses/emailInFile.py | 51 ++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 emailAdresses/emailInFile.py diff --git a/emailAdresses/emailInFile.py b/emailAdresses/emailInFile.py new file mode 100644 index 0000000..395deb3 --- /dev/null +++ b/emailAdresses/emailInFile.py @@ -0,0 +1,51 @@ +#! python3 +# emailInFile.py - Finds email addresses on a given file and copies them to the clipboard +# Usage: call the program with a file path as the first argument +# Example: >>> emailInFile.py C:\\Users\\ExampleUser\\Documents\\addresses.txt + +import pyperclip, re, sys, os + +# Create email regex. +emailRegex = re.compile(r'''( + [a-zA-Z0-9._%+-]+ # username + @ # @ symbol + [a-zA-Z0-9.-]+ # domain name + (\.[a-zA-Z]{2,4}) # dot-something + )''', re.VERBOSE) + +#Check if sys.argv[1] is given +argumentOne = "" +try: + argumentOne = sys.argv[1] +except IndexError: + exit("No second argument given. Try again with a file path as an argument") + +# Make absolute path if given path is a relative path +if(not os.path.isabs(argumentOne)): + argumentOne = os.path.abspath(argumentOne) + +openedContent = "" + +# Check if argumentOne is a valid path and file +if(os.path.exists(argumentOne) and os.path.isfile(argumentOne)): + # Try to open and read file + try: + openedFile = open(argumentOne, "r") + openedContent = openedFile.read() + except OSError: + exit("Could not open file") +else: + exit("Given file does not exist: " + argumentOne) + + +matches = [] +for groups in emailRegex.findall(openedContent): + emails = groups[0] + matches.append(emails) + +if len(matches) > 0: + pyperclip.copy(' -+- '.join(matches)) + print("Email address(es) found:") + print('\n'.join(matches)) +else: + print('No email address found.') From adab0e0e4df72bf47714e6305367e5d0e9a34123 Mon Sep 17 00:00:00 2001 From: Emil Merle Date: Wed, 9 Sep 2020 15:34:18 +0200 Subject: [PATCH 06/27] Added alliterationInClipboard.py --- alliterations/alliterationInClipboard.py | 23 +++++++++++++++++++++++ emailAdresses/emailInClipboard.py | 2 +- phoneNumbers/numberInClipboard.py | 2 +- 3 files changed, 25 insertions(+), 2 deletions(-) create mode 100644 alliterations/alliterationInClipboard.py diff --git a/alliterations/alliterationInClipboard.py b/alliterations/alliterationInClipboard.py new file mode 100644 index 0000000..f07efd4 --- /dev/null +++ b/alliterations/alliterationInClipboard.py @@ -0,0 +1,23 @@ +#! python3 +# alliterationInClipboard.py - Finds alliteration on the clipboard and copies them to the clipboard +# Usage: Copy some text and call the program +# Example: >>> alliterationInClipboard.py + +import pyperclip, re + +# Create alliteration regex. +alliRegex = re.compile(r"((\s)(\w)[a-z]*\s\3[a-z]*((\s\3[a-z]*)?)*)") + +# Find matches in clipboard text. +text = " " + str(pyperclip.paste()) +matches = [] +for groups in alliRegex.findall(text): + alliterations = groups[0][1:] # [1:] removes the space character + matches.append(alliterations) + +if len(matches) > 0: + pyperclip.copy(' -+- '.join(matches)) + print("Alliteration(s) found:") + print('\n'.join(matches)) +else: + print('No alliterations found.') diff --git a/emailAdresses/emailInClipboard.py b/emailAdresses/emailInClipboard.py index 027390b..5962172 100644 --- a/emailAdresses/emailInClipboard.py +++ b/emailAdresses/emailInClipboard.py @@ -1,6 +1,6 @@ #! python3 # emailInClipboard.py - Finds email addresses on the clipboard and copies them to the clipboard -# Usage: call the program +# Usage: Copy some text call the program # Example: >>> numberOnClipboard.py import pyperclip, re, sys diff --git a/phoneNumbers/numberInClipboard.py b/phoneNumbers/numberInClipboard.py index d631c41..f0949b2 100644 --- a/phoneNumbers/numberInClipboard.py +++ b/phoneNumbers/numberInClipboard.py @@ -1,6 +1,6 @@ #! python3 # numberInClipboard.py - Finds phone numbers on the clipboard and copies them to the clipboard -# Usage: call the program with a country as the first argument +# Usage: Copy some text and call the program with a country as the first argument # Example: >>> numberOnClipboard.py germany import pyperclip, re, sys From fc95a899cf0b4d249fb65591358c1815dcb0a321 Mon Sep 17 00:00:00 2001 From: Emil Merle Date: Wed, 9 Sep 2020 15:36:56 +0200 Subject: [PATCH 07/27] Improved logical structure --- emailAdresses/emailInFile.py | 15 +++++++-------- phoneNumbers/numberInFile.py | 1 - 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/emailAdresses/emailInFile.py b/emailAdresses/emailInFile.py index 395deb3..5175289 100644 --- a/emailAdresses/emailInFile.py +++ b/emailAdresses/emailInFile.py @@ -5,14 +5,6 @@ import pyperclip, re, sys, os -# Create email regex. -emailRegex = re.compile(r'''( - [a-zA-Z0-9._%+-]+ # username - @ # @ symbol - [a-zA-Z0-9.-]+ # domain name - (\.[a-zA-Z]{2,4}) # dot-something - )''', re.VERBOSE) - #Check if sys.argv[1] is given argumentOne = "" try: @@ -37,6 +29,13 @@ else: exit("Given file does not exist: " + argumentOne) +# Create email regex. +emailRegex = re.compile(r'''( + [a-zA-Z0-9._%+-]+ # username + @ # @ symbol + [a-zA-Z0-9.-]+ # domain name + (\.[a-zA-Z]{2,4}) # dot-something + )''', re.VERBOSE) matches = [] for groups in emailRegex.findall(openedContent): diff --git a/phoneNumbers/numberInFile.py b/phoneNumbers/numberInFile.py index f097f97..2126f9a 100644 --- a/phoneNumbers/numberInFile.py +++ b/phoneNumbers/numberInFile.py @@ -9,7 +9,6 @@ countryDict = {} #Create phone regex for country specific number format and add it to countryDict - germany = r'''( (\d{3}|\(\d{3}\))? # area code (optional) (\s|-|\.|/)? # separator (optional) From dc1ab4e7a3c010bed36d11a4c0cca88b07757356 Mon Sep 17 00:00:00 2001 From: Emil Merle <49149679+emilmerle@users.noreply.github.com> Date: Wed, 9 Sep 2020 15:42:36 +0200 Subject: [PATCH 08/27] Update README.md --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1c0cb9b..7c570f4 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,9 @@ # FindingThingsWithPython -Small and easy scripts to find things in texts with python. +Small and easy scripts to find things in texts with python. Feel free to contribute but please keep things easy to understand. + +## Imports (and use): +- pyperclip (copy and paste content from/to the clipboard) +- re (regular expressions) +- sys (command line arguments) +- os (functions for filepathes) From f2be89fb72c0d0571ef0a1215ffd86cede8d40c1 Mon Sep 17 00:00:00 2001 From: Emil Merle Date: Wed, 9 Sep 2020 16:11:46 +0200 Subject: [PATCH 09/27] Added alliterationInFile.py --- alliterations/alliterationInClipboard.py | 4 +- alliterations/alliterationInFile.py | 47 ++++++++++++++++++++++++ emailAdresses/emailInFile.py | 4 +- phoneNumbers/numberInFile.py | 2 + 4 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 alliterations/alliterationInFile.py diff --git a/alliterations/alliterationInClipboard.py b/alliterations/alliterationInClipboard.py index f07efd4..52d653e 100644 --- a/alliterations/alliterationInClipboard.py +++ b/alliterations/alliterationInClipboard.py @@ -6,7 +6,7 @@ import pyperclip, re # Create alliteration regex. -alliRegex = re.compile(r"((\s)(\w)[a-z]*\s\3[a-z]*((\s\3[a-z]*)?)*)") +alliRegex = re.compile(r"((\s)(\w)\w*\s\3\w*((\s\3\w*)?)*)", re.IGNORECASE) # Find matches in clipboard text. text = " " + str(pyperclip.paste()) @@ -20,4 +20,4 @@ print("Alliteration(s) found:") print('\n'.join(matches)) else: - print('No alliterations found.') + print('No alliteration found.') diff --git a/alliterations/alliterationInFile.py b/alliterations/alliterationInFile.py new file mode 100644 index 0000000..78ea382 --- /dev/null +++ b/alliterations/alliterationInFile.py @@ -0,0 +1,47 @@ +#! python3 +# alliterationInFile.py - Finds alliterations in a given file and copies them to the clipboard +# Usage: call the program with a file path as the first argument +# Example: >>> alliterationInFile.py C:\\Users\\ExampleUser\\Documents\\aRealText.txt + +import pyperclip, re, sys, os + +#Check if sys.argv[1] is given +argumentOne = "" +try: + argumentOne = sys.argv[1] +except IndexError: + exit("No second argument given. Try again with a file path as an argument") + +# Make absolute path if given path is a relative path +if(not os.path.isabs(argumentOne)): + argumentOne = os.path.abspath(argumentOne) + +openedContent = "" + +# Check if argumentOne is a valid path and file +if(os.path.exists(argumentOne) and os.path.isfile(argumentOne)): + # Try to open and read file + try: + openedFile = open(argumentOne, "r") + openedContent = openedFile.read() + except OSError: + exit("Could not open file") +else: + exit("Given file does not exist: " + argumentOne) + +# Create alliteration regex. +alliRegex = re.compile(r"((\s)(\w)\w*\s\3\w*((\s\3\w*)?)*)", re.IGNORECASE) + +matches = [] +for groups in alliRegex.findall(openedContent): + alliterations = groups[0][1:] + matches.append(alliterations) + +openedFile.close() + +if len(matches) > 0: + pyperclip.copy(' -+- '.join(matches)) + print("Alliteration(s) found:") + print('\n'.join(matches)) +else: + print('No alliteration found.') diff --git a/emailAdresses/emailInFile.py b/emailAdresses/emailInFile.py index 5175289..6729a0b 100644 --- a/emailAdresses/emailInFile.py +++ b/emailAdresses/emailInFile.py @@ -1,5 +1,5 @@ #! python3 -# emailInFile.py - Finds email addresses on a given file and copies them to the clipboard +# emailInFile.py - Finds email addresses in a given file and copies them to the clipboard # Usage: call the program with a file path as the first argument # Example: >>> emailInFile.py C:\\Users\\ExampleUser\\Documents\\addresses.txt @@ -42,6 +42,8 @@ emails = groups[0] matches.append(emails) +openedFile.close() + if len(matches) > 0: pyperclip.copy(' -+- '.join(matches)) print("Email address(es) found:") diff --git a/phoneNumbers/numberInFile.py b/phoneNumbers/numberInFile.py index 2126f9a..9107d05 100644 --- a/phoneNumbers/numberInFile.py +++ b/phoneNumbers/numberInFile.py @@ -60,6 +60,8 @@ phoneNumber = groups[0] matches.append(phoneNumber) +openedFile.close() + if len(matches) > 0: pyperclip.copy(' -+- '.join(matches)) print("Phone number(s) found:") From 568c76a99d5bccbe73bf0b5a6dd89276bfb0aad4 Mon Sep 17 00:00:00 2001 From: Finn Kranzosch Date: Thu, 24 Sep 2020 22:40:02 +0200 Subject: [PATCH 10/27] Added german readme and link to other languages --- README.md | 3 +++ README_de.md | 12 ++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 README_de.md diff --git a/README.md b/README.md index 7c570f4..c3111e5 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,6 @@ Feel free to contribute but please keep things easy to understand. - re (regular expressions) - sys (command line arguments) - os (functions for filepathes) + +## READMEs in other languages: +- [German](README_de.md) \ No newline at end of file diff --git a/README_de.md b/README_de.md new file mode 100644 index 0000000..061a247 --- /dev/null +++ b/README_de.md @@ -0,0 +1,12 @@ +# FindingThingsWithPython +Kleine und einfache Skripte, um diverse Sachen in Texten mithilfe von python zu finden. +Du kannst gerne etwas beitragen, aber bitte halte die Dinge leicht und verständlich. + +## Imports (und Nutzung von): +- pyperclip (Kopieren und Einfügen von Inhalt der Zwischenablage) +- re (regular expressions) +- sys (Kommandozeilenargumente) +- os (Funktionen für die Dateipfade) + +## READMEs in anderen Sprachen: +- [English](README.md) \ No newline at end of file From bb3de9f4b69a2ef4debebcb30cf121016d883352 Mon Sep 17 00:00:00 2001 From: Yorozuya3 Date: Fri, 25 Sep 2020 18:42:02 +0200 Subject: [PATCH 11/27] Add gitignore. Ignore enviroments files. --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b1fa6e9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +#Ignore enviroment files +/env From 7361829e18cf42373dd4716fdc2c1ac310bea634 Mon Sep 17 00:00:00 2001 From: Yorozuya3 Date: Fri, 25 Sep 2020 18:42:55 +0200 Subject: [PATCH 12/27] Add requirements file. Add pyperclip to requirements. --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e324c54 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyperclip==1.8.0 From d3f10fb8a5027a4ab77349517b7c804c3accc75f Mon Sep 17 00:00:00 2001 From: rexdivakar Date: Sat, 26 Sep 2020 13:22:06 +0530 Subject: [PATCH 13/27] Added Requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e324c54 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +pyperclip==1.8.0 From f3490d32b7393d856970e7552468edac4a45423e Mon Sep 17 00:00:00 2001 From: rexdivakar Date: Sat, 26 Sep 2020 14:14:41 +0530 Subject: [PATCH 14/27] fixed encoding issues --- alliterations/alliterationInFile.py | 2 +- emailAdresses/emailInFile.py | 2 +- phoneNumbers/numberInFile.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/alliterations/alliterationInFile.py b/alliterations/alliterationInFile.py index 78ea382..a5050c4 100644 --- a/alliterations/alliterationInFile.py +++ b/alliterations/alliterationInFile.py @@ -22,7 +22,7 @@ if(os.path.exists(argumentOne) and os.path.isfile(argumentOne)): # Try to open and read file try: - openedFile = open(argumentOne, "r") + openedFile = open(argumentOne, "r",encoding='ascii',errors='ignore') openedContent = openedFile.read() except OSError: exit("Could not open file") diff --git a/emailAdresses/emailInFile.py b/emailAdresses/emailInFile.py index 6729a0b..9960a69 100644 --- a/emailAdresses/emailInFile.py +++ b/emailAdresses/emailInFile.py @@ -22,7 +22,7 @@ if(os.path.exists(argumentOne) and os.path.isfile(argumentOne)): # Try to open and read file try: - openedFile = open(argumentOne, "r") + openedFile = open(argumentOne, "r",encoding='ascii',errors='ignore') openedContent = openedFile.read() except OSError: exit("Could not open file") diff --git a/phoneNumbers/numberInFile.py b/phoneNumbers/numberInFile.py index 9107d05..0d632be 100644 --- a/phoneNumbers/numberInFile.py +++ b/phoneNumbers/numberInFile.py @@ -47,7 +47,7 @@ if(os.path.exists(argumentTwo) and os.path.isfile(argumentTwo)): # Try to open and read file try: - openedFile = open(argumentTwo, "r") + openedFile = open(argumentTwo, "r",encoding='ascii',errors='ignore') openedContent = openedFile.read() except OSError: exit("Could not open file") From d226b3f58451e3fede2200c5514b241f9a24f884 Mon Sep 17 00:00:00 2001 From: Emil Merle <49149679+emilmerle@users.noreply.github.com> Date: Sun, 27 Sep 2020 13:10:15 +0200 Subject: [PATCH 15/27] Update README.md --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c3111e5..f1c8b44 100644 --- a/README.md +++ b/README.md @@ -8,5 +8,13 @@ Feel free to contribute but please keep things easy to understand. - sys (command line arguments) - os (functions for filepathes) +## How to contribute: +1. Fork this repository. +2. Clone the forked repository. +3. Write your code +4. Create a new branch +5. Open a pull request +See [this tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github) for more information. + ## READMEs in other languages: -- [German](README_de.md) \ No newline at end of file +- [German](README_de.md) From 076a22f2042f0d576525779d8bd88b2d88d015ac Mon Sep 17 00:00:00 2001 From: Emil Merle <49149679+emilmerle@users.noreply.github.com> Date: Sun, 27 Sep 2020 13:10:29 +0200 Subject: [PATCH 16/27] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f1c8b44..3f84cb4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ Feel free to contribute but please keep things easy to understand. 3. Write your code 4. Create a new branch 5. Open a pull request + See [this tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github) for more information. ## READMEs in other languages: From d5076b1d9ceccc066c835701f64162b620eb48d3 Mon Sep 17 00:00:00 2001 From: Ilkom Pendek Date: Sun, 27 Sep 2020 21:52:46 +0700 Subject: [PATCH 17/27] Added Bahasa Indonesia readme and link to other languages --- README_idn.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 README_idn.md diff --git a/README_idn.md b/README_idn.md new file mode 100644 index 0000000..fa6e533 --- /dev/null +++ b/README_idn.md @@ -0,0 +1,13 @@ +# FindingThingsWithPython +Skrip singkat dan mudah untuk menemukan teks dengan bahasa pemrograman python. +Silahkan untuk berkonrtibusi. Harap tetap menjaga agar dapat tetap mudah dimengerti/ dipahami. + +## Imports (dan penggunaan): +- pyperclip (copy (salin) dan paste (tempel) konten dari/ke clipboard) +- re (ekspresi regular) +- sys (argumen command line) +- os (fungsi untuk filepathes (alur file)) + +## READMEs in other languages: +- [German](README_de.md) +- [Indonesia](README_idn.md) \ No newline at end of file From 70e19a831c40ce66e1a9a5b685720f1fbed092cf Mon Sep 17 00:00:00 2001 From: iriyagupta Date: Mon, 28 Sep 2020 01:49:44 +0530 Subject: [PATCH 18/27] README in hi --- README.md | 1 + README_de.md | 3 ++- README_hi.md | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 README_hi.md diff --git a/README.md b/README.md index 3f84cb4..bd70225 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,4 @@ See [this tutorial](https://www.digitalocean.com/community/tutorials/how-to-crea ## READMEs in other languages: - [German](README_de.md) +- [Hindi](README_hi.md) diff --git a/README_de.md b/README_de.md index 061a247..9af982d 100644 --- a/README_de.md +++ b/README_de.md @@ -9,4 +9,5 @@ Du kannst gerne etwas beitragen, aber bitte halte die Dinge leicht und verständ - os (Funktionen für die Dateipfade) ## READMEs in anderen Sprachen: -- [English](README.md) \ No newline at end of file +- [English](README.md) +- [Hindi](README_hi.md) diff --git a/README_hi.md b/README_hi.md new file mode 100644 index 0000000..f0c3753 --- /dev/null +++ b/README_hi.md @@ -0,0 +1,23 @@ +# पाइथन के साथ खोजें (FindingThingsWithPython) +पाइथन के साथ ग्रंथो/टेक्स्ट में चीजों को खोजने के लिए छोटी और आसान स्क्रिप्ट्स | +योगदान करने के लिए स्वतंत्र महसूस करें लेकिन कृपया चीजों को समझने में आसान रखें। + +## आयात (और उपयोग)[Imports (and use)] : +इन्हें पाइथन में आयात करें +- pyperclip (क्लिपबोर्ड पर / से सामग्री कॉपी और पेस्ट करे) +- re (regular expressions) +- sys (command line arguments) +- os (फाइल paths के लिए functions) + +## योगदान कैसे करें: +1. इस Repository को Fork कीजिये +2. Fork की हुई repository को clone करें +3. Code लिखें +4. नयी branch बनाएं +5. Pull request करें + +## अन्य भाषाओँ में READMEs : +- [English](README.md) +- [German](README_de.md) + + From a18bd04e2a2f23b86730c011d91cc324b29d38b6 Mon Sep 17 00:00:00 2001 From: Ilkom Pendek Date: Mon, 28 Sep 2020 08:37:02 +0700 Subject: [PATCH 19/27] Added Bahasa Indonesia readme and link to other languages --- README_idn.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README_idn.md b/README_idn.md index fa6e533..3d7127d 100644 --- a/README_idn.md +++ b/README_idn.md @@ -9,5 +9,6 @@ Silahkan untuk berkonrtibusi. Harap tetap menjaga agar dapat tetap mudah dimenge - os (fungsi untuk filepathes (alur file)) ## READMEs in other languages: +- [English](README.md) - [German](README_de.md) - [Indonesia](README_idn.md) \ No newline at end of file From 9351e48fa86680b4f706f7383ab3b76e63548944 Mon Sep 17 00:00:00 2001 From: Ilkom Pendek Date: Mon, 28 Sep 2020 22:17:20 +0700 Subject: [PATCH 20/27] Added link to indonesia version in english version --- README.md | 1 + README_de.md | 3 ++- README_idn.md | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3f84cb4..9571906 100644 --- a/README.md +++ b/README.md @@ -19,3 +19,4 @@ See [this tutorial](https://www.digitalocean.com/community/tutorials/how-to-crea ## READMEs in other languages: - [German](README_de.md) +- [Indonesia](README_idn.md) diff --git a/README_de.md b/README_de.md index 061a247..e0e5841 100644 --- a/README_de.md +++ b/README_de.md @@ -9,4 +9,5 @@ Du kannst gerne etwas beitragen, aber bitte halte die Dinge leicht und verständ - os (Funktionen für die Dateipfade) ## READMEs in anderen Sprachen: -- [English](README.md) \ No newline at end of file +- [English](README.md) +- [Indonesia](README_idn.md) \ No newline at end of file diff --git a/README_idn.md b/README_idn.md index 3d7127d..3259d21 100644 --- a/README_idn.md +++ b/README_idn.md @@ -10,5 +10,4 @@ Silahkan untuk berkonrtibusi. Harap tetap menjaga agar dapat tetap mudah dimenge ## READMEs in other languages: - [English](README.md) -- [German](README_de.md) -- [Indonesia](README_idn.md) \ No newline at end of file +- [German](README_de.md) \ No newline at end of file From b27b2c03ace26ea74000ed4266b8516ad4803860 Mon Sep 17 00:00:00 2001 From: iriyagupta Date: Mon, 28 Sep 2020 21:38:50 +0530 Subject: [PATCH 21/27] updated hi for tut --- README_hi.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README_hi.md b/README_hi.md index f0c3753..8d5487f 100644 --- a/README_hi.md +++ b/README_hi.md @@ -16,6 +16,8 @@ 4. नयी branch बनाएं 5. Pull request करें +अधिक जानकारी के लिए [इस ट्यूटोरियल] (https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github) को देखें | + ## अन्य भाषाओँ में READMEs : - [English](README.md) - [German](README_de.md) From 9296a11e8f62cefa83b93426469f8f67548ea108 Mon Sep 17 00:00:00 2001 From: Riya Gupta <15695755+iriyagupta@users.noreply.github.com> Date: Mon, 28 Sep 2020 21:39:36 +0530 Subject: [PATCH 22/27] Update README_hi.md --- README_hi.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README_hi.md b/README_hi.md index 8d5487f..152c1f5 100644 --- a/README_hi.md +++ b/README_hi.md @@ -16,7 +16,7 @@ 4. नयी branch बनाएं 5. Pull request करें -अधिक जानकारी के लिए [इस ट्यूटोरियल] (https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github) को देखें | +अधिक जानकारी के लिए [इस ट्यूटोरियल](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github) को देखें | ## अन्य भाषाओँ में READMEs : - [English](README.md) From b5e4b363aa8b02a370ea5e6e9f7ceb83b7ac510a Mon Sep 17 00:00:00 2001 From: Yorozuya3 Date: Mon, 28 Sep 2020 21:08:57 +0200 Subject: [PATCH 23/27] Add regex expresion for spanish phone numbers. It gets all 9-digit numbers which start by 9 or 8. --- phoneNumbers/numberInFile.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/phoneNumbers/numberInFile.py b/phoneNumbers/numberInFile.py index 9107d05..3f88c0d 100644 --- a/phoneNumbers/numberInFile.py +++ b/phoneNumbers/numberInFile.py @@ -14,8 +14,10 @@ (\s|-|\.|/)? # separator (optional) (\d{7,9}) # 7 to 9 digits )''' -countryDict["germany"] = germany +spain = r"(^[98](\d{8}))" +countryDict["germany"] = germany +countryDict["spain"] = spain # Check if sys.argv[1] is given and in countryDict argumentOne = "" try: @@ -25,7 +27,7 @@ if(argumentOne in countryDict): #Create regex object - regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE) + regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE|re.MULTILINE) else: exit("No number format for that country found") @@ -63,8 +65,8 @@ openedFile.close() if len(matches) > 0: - pyperclip.copy(' -+- '.join(matches)) + # pyperclip.copy(' -+- '.join(matches)) print("Phone number(s) found:") print('\n'.join(matches)) else: - print('No phone numbers or email addresses found.') \ No newline at end of file + print('No phone numbers or email addresses found.') From 5ac16012ffb684a8ee8a555ae075409518056cca Mon Sep 17 00:00:00 2001 From: Yorozuya3 Date: Mon, 28 Sep 2020 21:13:30 +0200 Subject: [PATCH 24/27] Revert "Add regex expresion for spanish phone numbers." This reverts commit b5e4b363aa8b02a370ea5e6e9f7ceb83b7ac510a. pyperclip line is still commented. --- phoneNumbers/numberInFile.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/phoneNumbers/numberInFile.py b/phoneNumbers/numberInFile.py index 3f88c0d..9107d05 100644 --- a/phoneNumbers/numberInFile.py +++ b/phoneNumbers/numberInFile.py @@ -14,10 +14,8 @@ (\s|-|\.|/)? # separator (optional) (\d{7,9}) # 7 to 9 digits )''' -spain = r"(^[98](\d{8}))" - countryDict["germany"] = germany -countryDict["spain"] = spain + # Check if sys.argv[1] is given and in countryDict argumentOne = "" try: @@ -27,7 +25,7 @@ if(argumentOne in countryDict): #Create regex object - regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE|re.MULTILINE) + regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE) else: exit("No number format for that country found") @@ -65,8 +63,8 @@ openedFile.close() if len(matches) > 0: - # pyperclip.copy(' -+- '.join(matches)) + pyperclip.copy(' -+- '.join(matches)) print("Phone number(s) found:") print('\n'.join(matches)) else: - print('No phone numbers or email addresses found.') + print('No phone numbers or email addresses found.') \ No newline at end of file From a56155e03dae11a571c1e480753b3867659d85e7 Mon Sep 17 00:00:00 2001 From: Yorozuya3 Date: Mon, 28 Sep 2020 21:21:54 +0200 Subject: [PATCH 25/27] Add regex expression for spanish phone number from a file. It gets all 9 digit numbers which start by 9 or 8. --- phoneNumbers/numberInFile.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/phoneNumbers/numberInFile.py b/phoneNumbers/numberInFile.py index 9107d05..2c05b67 100644 --- a/phoneNumbers/numberInFile.py +++ b/phoneNumbers/numberInFile.py @@ -14,8 +14,10 @@ (\s|-|\.|/)? # separator (optional) (\d{7,9}) # 7 to 9 digits )''' -countryDict["germany"] = germany +spain = r"(^[98](\d{8}))" +countryDict["germany"] = germany +countryDict["spain"] = spain # Check if sys.argv[1] is given and in countryDict argumentOne = "" try: @@ -25,7 +27,7 @@ if(argumentOne in countryDict): #Create regex object - regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE) + regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE|re.MULTILINE) else: exit("No number format for that country found") @@ -67,4 +69,4 @@ print("Phone number(s) found:") print('\n'.join(matches)) else: - print('No phone numbers or email addresses found.') \ No newline at end of file + print('No phone numbers or email addresses found.') From 1d0aa4e38987561769ba99e41501d7d4ee346c45 Mon Sep 17 00:00:00 2001 From: Yorozuya3 Date: Mon, 28 Sep 2020 21:25:58 +0200 Subject: [PATCH 26/27] Add regex expresion for spanish numbers. --- phoneNumbers/numberInClipboard.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/phoneNumbers/numberInClipboard.py b/phoneNumbers/numberInClipboard.py index f0949b2..1288736 100644 --- a/phoneNumbers/numberInClipboard.py +++ b/phoneNumbers/numberInClipboard.py @@ -15,8 +15,9 @@ (\s|-|\.|/)? # separator (optional) (\d{7,9}) # 7 to 9 digits )''' +spain = r"(^[98](\d{8}))" countryDict["germany"] = germany - +countryDict["spain"] = spain # Check if sys.argv[1] in countryDict and create regex object argumentOne = "" @@ -27,7 +28,7 @@ if(argumentOne in countryDict): #Create regex object - regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE) + regexCompile = re.compile(countryDict[argumentOne], re.VERBOSE|re.MULTILINE) else: exit("No number format for that country found") From 3d9ab6ac4c88b302cf625a26d46756e090bb1dfa Mon Sep 17 00:00:00 2001 From: Finn Kranzosch Date: Thu, 1 Oct 2020 14:13:52 +0200 Subject: [PATCH 27/27] Extended and fixed READMEs --- README.md | 4 ++-- README_de.md | 9 +++++++++ README_hi.md | 2 +- README_idn.md | 3 ++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index db3fddb..e538edb 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Feel free to contribute but please keep things easy to understand. - os (functions for filepathes) ## How to contribute: -1. Fork this repository. -2. Clone the forked repository. +1. Fork this repository +2. Clone the forked repository 3. Write your code 4. Create a new branch 5. Open a pull request diff --git a/README_de.md b/README_de.md index 3377a80..5f1fa69 100644 --- a/README_de.md +++ b/README_de.md @@ -8,6 +8,15 @@ Du kannst gerne etwas beitragen, aber bitte halte die Dinge leicht und verständ - sys (Kommandozeilenargumente) - os (Funktionen für die Dateipfade) +## So trägst du etwas bei: +1. Dieses Repository forken +2. Klonen des geforkten Repositories +3. Neuen Code hinzufügen +4. Neuen Branch erstellen +5. Pull-Request eröffnen + +[Dieses Tutorial](https://www.digitalocean.com/community/tutorials/how-to-create-a-pull-request-on-github) beinhaltet noch weiterführende Informationen. + ## READMEs in anderen Sprachen: - [English](README.md) - [Hindi](README_hi.md) diff --git a/README_hi.md b/README_hi.md index 152c1f5..e0622de 100644 --- a/README_hi.md +++ b/README_hi.md @@ -21,5 +21,5 @@ ## अन्य भाषाओँ में READMEs : - [English](README.md) - [German](README_de.md) - +- [Indonesia](README_idn.md) diff --git a/README_idn.md b/README_idn.md index 3259d21..bb82078 100644 --- a/README_idn.md +++ b/README_idn.md @@ -10,4 +10,5 @@ Silahkan untuk berkonrtibusi. Harap tetap menjaga agar dapat tetap mudah dimenge ## READMEs in other languages: - [English](README.md) -- [German](README_de.md) \ No newline at end of file +- [German](README_de.md) +- [Hindi](README_hi.md) \ No newline at end of file