diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 6c87862..76767f0 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,11 +3,9 @@
-
-
-
-
-
+
+
+
@@ -17,11 +15,47 @@
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -36,6 +70,12 @@
+
+
+ i18n
+ valid
+
+
@@ -47,10 +87,12 @@
+
+
-
+
@@ -61,7 +103,6 @@
-
@@ -69,6 +110,16 @@
+
+
+
+
+
+
+
+
+
+
@@ -77,9 +128,11 @@
+
+
@@ -136,9 +189,10 @@
-
+
+
-
+
@@ -167,44 +221,51 @@
-
+
+
+
+
+
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
-
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
+
+
+
diff --git a/notepostcli/api.py b/notepostcli/api.py
index 0250d14..d6e3f86 100644
--- a/notepostcli/api.py
+++ b/notepostcli/api.py
@@ -4,7 +4,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-import i18n
import requests
from config import getconfig
@@ -15,7 +14,7 @@ def do(action, data={}):
try:
r = requests.post(conf["url"] + "/api/" + action, data=data, auth=(conf["username"], conf["password"]))
except:
- print(i18n.t("Could not connect to the server. Try again."))
+ print("Could not connect to the server. Try again.")
return
try:
@@ -24,4 +23,4 @@ def do(action, data={}):
raise Exception(resp["msg"])
return resp
except ValueError:
- raise Exception(i18n.t("Invalid response from server."))
+ raise Exception("Invalid response from server.")
diff --git a/notepostcli/notepost.py b/notepostcli/notepost.py
index 1660dfc..c61ef24 100755
--- a/notepostcli/notepost.py
+++ b/notepostcli/notepost.py
@@ -12,9 +12,8 @@ except:
pass
import tempfile
-import i18n
-import validators
import requests
+import re
import api
from config import *
from termcolors import *
@@ -30,36 +29,36 @@ def firstsetup(url="", username=""):
# Get URL
while True:
if url != "":
- url = input(i18n.t("Server URL") + " (" + url + "): ") or url
+ url = input("Server URL (" + url + "): ") or url
else:
- url = input(i18n.t("Server URL") + ": ")
- if validators.url(url):
+ url = input("Server URL: ")
+ if re.compile("^(https?|ftp)://[^\s/$.?#].[^\s]*$").match(url):
break
else:
- print(i18n.t("That doesn't look right, try again."))
+ print("That doesn't look right, try again.")
# Get username
while True:
if username != "":
- username = input(i18n.t("Username") + " (" + username + "): ") or username
+ username = input("Username (" + username + "): ") or username
else:
- username = input(i18n.t("Username") + ": ")
+ username = input("Username: ")
if username != "":
break
# Get password
while True:
- password = getpass(i18n.t("Password") + ": ")
+ password = getpass("Password: ")
if password != "":
break
try:
r = requests.post(url + "/api/ping", auth=(username, password))
except:
- print(i18n.t("Could not connect to the server. Try again."))
+ print("Could not connect to the server. Try again.")
firstsetup()
return
if r.status_code == 401:
- print(i18n.t("Login incorrect, try again."))
+ print("Login incorrect, try again.")
firstsetup(url)
return
@@ -75,7 +74,7 @@ def firstsetup(url="", username=""):
saveconfig()
return
except ValueError:
- print(i18n.t("Login incorrect, try again."))
+ print("Login incorrect, try again.")
firstsetup(url, username)
return
@@ -106,13 +105,15 @@ def editnote(note):
assert not os.path.exists(f.name)
note["content"] = text
clearscreen()
- print(i18n.t("Saving..."))
+ print("Saving...")
savenote(note)
- print(i18n.t("Note saved!"))
+ print("Note saved!")
def editmenu():
global notes
+ rows, columns = os.popen('stty size', 'r').read().split()
+ linelength = int(columns) - 10
clearscreen()
loadnotes()
i = 1
@@ -128,21 +129,21 @@ def editmenu():
if linecount > 5:
print("\n(" + str(len(note["content"].splitlines())) + " more lines" + ")", end='')
break
- print("\n " + line[0:70].ljust(70), end='')
- if len(line) > 70:
+ print("\n " + line[0:linelength].ljust(linelength), end='')
+ if len(line) > linelength:
print("...", end='')
linecount += 1
i += 1
resetcolor()
print("\n======================")
- noteid = input(i18n.t("Note to edit (M for main menu): "))
+ noteid = input("Note to edit (M for main menu): ")
if noteid.upper() == "M":
clearscreen()
return
try:
editnote(notelist[noteid])
except KeyError:
- print(i18n.t("Invalid selection."))
+ print("Invalid selection.")
def newnote():
@@ -159,23 +160,23 @@ def newnote():
assert not os.path.exists(f.name)
if text == "":
clearscreen()
- print(i18n.t("Nothing to do."))
+ print("Nothing to do.")
return
- print(i18n.t("Saving..."))
+ print("Saving...")
api.do("savenote", {
"text": text
})
- print(i18n.t("Note created!"))
+ print("Note created!")
def mainmenu():
print("\n======================")
- print(i18n.t("Main Menu"))
+ print("Main Menu")
print("======================")
- print("E. " + i18n.t("View and edit notes"))
- print("C. " + i18n.t("Create a new note"))
- print("Q. " + i18n.t("Exit"))
- option = input(i18n.t("Choose an option: ")).upper()
+ print("E. View and edit notes")
+ print("C. Create a new note")
+ print("Q. Exit")
+ option = input("Choose an option: ").upper()
clearscreen()
if option == "E":
editmenu()
@@ -184,13 +185,13 @@ def mainmenu():
elif option == "Q":
exit(0)
else:
- print(i18n.t("Unrecognized selection, try again."))
+ print("Unrecognized selection, try again.")
def main():
print("NotePostCLI v0.1")
if not checkconfig():
- print(i18n.t("No valid settings file found, running setup wizard."))
+ print("No valid settings file found, running setup wizard.")
firstsetup()
else:
loadconfig()
diff --git a/setup.py b/setup.py
index 573a678..d1d7f57 100644
--- a/setup.py
+++ b/setup.py
@@ -4,7 +4,7 @@
from setuptools import setup, find_packages
setup(
name="NotePostCLI",
- version="0.1.2",
+ version="0.1.3",
packages=find_packages(),
install_requires=[
"appdirs>=1.4.3",
@@ -12,11 +12,9 @@ setup(
"chardet>=3.0",
"decorator>=4.1",
"idna>=2.6",
- "python-i18n==0.3.5",
"requests>=2.18.0",
- "six>=1.11.0",
- "urllib3>=1.22",
- "validators==0.12.3"
+ "six>=1.10.0",
+ "urllib3>=1.22"
],
entry_points = {
'console_scripts' : ['notepostcli = notepostcli.notepost:main']