Skip to content

Commit

Permalink
Merge with upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian S. Pringle committed Oct 1, 2020
2 parents c6575d1 + 3c73d45 commit fda6832
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 111 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
<<<<<<< HEAD

# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

Expand Down Expand Up @@ -143,4 +141,3 @@ dmypy.json
=======
#Ignore enviroment files
/env
>>>>>>> 3c73d451606203216ef00f7bfb7a176bce5a8c43
26 changes: 0 additions & 26 deletions alliterations/alliterationInFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def main():
# Check if sys.argv[1] is given
argumentOne = ""
try:
<<<<<<< HEAD
argumentOne = sys.argv[1]
except IndexError:
exit("No second argument given. "
Expand Down Expand Up @@ -53,28 +52,3 @@ def main():

if __name__ == "__main__":
main()
=======
openedFile = open(argumentOne, "r",encoding='ascii',errors='ignore')
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.')
>>>>>>> 3c73d451606203216ef00f7bfb7a176bce5a8c43
31 changes: 0 additions & 31 deletions emailAdresses/emailInFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ def main():
# Check if sys.argv[1] is given
argumentOne = ""
try:
<<<<<<< HEAD
argumentOne = sys.argv[1]
except IndexError:
exit("No second argument given. "
Expand Down Expand Up @@ -53,33 +52,3 @@ def main():

if __name__ == "__main__":
main()
=======
openedFile = open(argumentOne, "r",encoding='ascii',errors='ignore')
openedContent = openedFile.read()
except OSError:
exit("Could not open file")
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):
emails = groups[0]
matches.append(emails)

openedFile.close()

if len(matches) > 0:
pyperclip.copy(' -+- '.join(matches))
print("Email address(es) found:")
print('\n'.join(matches))
else:
print('No email address found.')
>>>>>>> 3c73d451606203216ef00f7bfb7a176bce5a8c43
47 changes: 0 additions & 47 deletions phoneNumbers/numberInFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
>>> numberInFile.py germany C:\\Users\\ExampleUser\\Documents\\phoneNumbers.txt
"""

<<<<<<< HEAD
from countries import countryDict
import pyperclip
import re
Expand All @@ -26,30 +25,6 @@ def main():
except IndexError:
exit("No argument given."
" Try again with a country as an argument")
=======
#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
)'''
spain = r"(^[98](\d{8}))"

countryDict["germany"] = germany
countryDict["spain"] = spain
# 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|re.MULTILINE)
else:
exit("No number format for that country found")
>>>>>>> 3c73d451606203216ef00f7bfb7a176bce5a8c43

if(argumentOne in countryDict):
# Create regex object
Expand All @@ -71,7 +46,6 @@ def main():

openedContent = ""

<<<<<<< HEAD
# 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
Expand All @@ -90,18 +64,6 @@ def main():
matches.append(phoneNumber)

openedFile.close()
=======
# 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",encoding='ascii',errors='ignore')
openedContent = openedFile.read()
except OSError:
exit("Could not open file")
else:
exit("Given file does not exist: " + argumentTwo)
>>>>>>> 3c73d451606203216ef00f7bfb7a176bce5a8c43

if len(matches) > 0:
pyperclip.copy(' -+- '.join(matches))
Expand All @@ -111,14 +73,5 @@ def main():
print('No phone numbers or email addresses found.')


<<<<<<< HEAD
if __name__ == "__main__":
main()
=======
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.')
>>>>>>> 3c73d451606203216ef00f7bfb7a176bce5a8c43
4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1 @@
<<<<<<< HEAD
pyperclip == 1.8.0
=======
pyperclip==1.8.0
>>>>>>> 3c73d451606203216ef00f7bfb7a176bce5a8c43

0 comments on commit fda6832

Please sign in to comment.