def initialize(voice_command,sentences): ac_username = "******" with open("config/accounts.blue","r") as f: for line in f.read().splitlines(): if loads(line)['service'] == "simplenote": ac_username = loads(line)['username'] f.close() break if ac_username == "null": return False, "Vous n'avez pas encore enregistré votre compte simplenote.com" else: ac_password = get_password("simplenote",ac_username) sn = simplenote.Simplenote(ac_username, ac_password) #trying to get assistant default note page found = False for note in sn.get_note_list(): if note == 0: break if get_assistant_name() in note[0]['tags']: response = note[0]['content'] found = True break if not found: # note page of your assistant doesn't exists response = "Vous n'avez pas encore pris de notes." return True, response
def GetSimpleNoteEntires(userid, password, verbose=False): try: if verbose: print('Fetching notes from simplenote.com...') sn_conn = simplenote.Simplenote(userid, password) nlist = sn_conn.get_note_list()[0] if verbose: print('{0} Notes fetched from simplenote.com'.format(len(nlist))) return nlist except: # For now we will ignore errors return []
def initialize(voice_command,sentences): #remove trigger words to get only the valuable data for sentence in sentences: for part in sentence.split("*"): voice_command = voice_command.replace(part,"",1) #check if the external service "simplenote" has been registered if not is_service_registered("simplenote"): register_service("simplenote") #check if user has registered an simplenote account if is_user_account_for_service("simplenote"): #an account has been registered, getting his username ac_username = get_username_for_service("simplenote") # no account available for this service, returning some sentences to guide him else: return False, "Vous n'avez pas encore enregistré votre compte simplenote.com" #getting password from secure keyring ac_password = get_password("simplenote",ac_username) #connecting to simplenote sn = simplenote.Simplenote(ac_username,ac_password ) #trying to get assistant default note page found = False for note in sn.get_note_list(): if note == 0: break if get_assistant_name() in note[0]['tags']: note_key = note[0]['key'] content = str(note[0]['content']) new_content = "" for line in content.splitlines(): if SequenceMatcher(line,voice_command) < 0.8: new_content += f"{line}\n" sn.update_note({'key':note_key,'tags':[get_assistant_name()],'content':new_content}) found = True break if not found: # note page of your assistant doesn't exists, creating one sn.add_note({'tags':[get_assistant_name()],'content':''}) return True, f"j'ai enlevé {voice_command} de vos notes"
def backup(folder, user, password, ext='.mdtxt', pub_tag='published', **kwargs): os.makedirs(folder, exist_ok=True) sn = simplenote.Simplenote(user, password) note_list = sn.get_note_list() note_list = note_list[0] for i, note in enumerate(note_list): print("Processing note {} of {}.".format(i, len(note_list))) if note['deleted']: continue if pub_tag not in note['tags']: continue individual_note = sn.get_note(note['key']) individual_note = individual_note[0] note_path_md = os.path.join(folder, note['key'] + ext) data = {} tags = [ tag for tag in individual_note['tags'] if not tag.startswith('category_') ] tags = [tag for tag in tags if tag != pub_tag] categories = [ tag.partition('category_')[2] for tag in individual_note['tags'] if tag.startswith('category_') ] content = individual_note['content'].strip().split('\n') data['title'] = content[0].lstrip('# ') data['content'] = '\n'.join(content[1:]) creation_date = dt.utcfromtimestamp( float(individual_note['createdate'])) modification_date = dt.utcfromtimestamp( float(individual_note['modifydate'])) creation_date = creation_date.replace(microsecond=0) modification_date = modification_date.replace(microsecond=0) data['categories'] = ' '.join(categories) data['tags'] = ' '.join(tags) data['status'] = 'published' data['slug'] = slugify(data['title']) data['creation_date'] = creation_date.isoformat(' ') data['modification_date'] = modification_date.isoformat(' ') md_content = post_fmt.format(**data) with open(note_path_md, 'w') as f: f.write(md_content)
def main(): username = os.getenv('SIMPLENOTE_USER') password = os.getenv('SIMPLENOTE_PASSWD') directory = os.path.expanduser( os.getenv('JEKYLL_POSTS_DIR', os.path.join(os.getcwd(), '_posts'))) if not os.path.exists(directory): os.makedirs(directory) sn = simplenote.Simplenote(username, password) note_list, status = sn.get_note_list(tags=['blog']) for meta in note_list: note, status = sn.get_note(meta['key']) data = process_note(note) full_path = os.path.join(directory, data['filename']) front_matter = compile_frontmatter(data) with open(full_path, 'w') as f: f.write('\n\n'.join([front_matter, data['content']]))
def __init__(self, username, password): self.simplenote = simplenote.Simplenote(username, password) # Storing keys/ids for the note list self.note_index = [] # Lightweight "cache" of note data for note index self.note_cache = {} if int(vim.eval("exists('g:vader_file')")) == 0: if os.path.isfile(INDEX_CACHE_FILE): try: with open(INDEX_CACHE_FILE, 'r') as f: cache_file = json.load(f) self.note_cache = cache_file["cache"] self.simplenote.current = cache_file["current"] except IOError as e: print("Error: Unable to read index cache to file - %s" % e) # TODO: Maybe possible to merge the following with note_cache now? self.note_version = {} # Map bufnums to noteids self.bufnum_to_noteid = {} # Default Window width for single window mode - other things override this self.vertical_window_width = 0
def get_simplenote(attempts=5): """Attempt to authenticate and return a Simplenote instance.""" username = input("Username: "******"SN_PSWD"] except KeyError as exception: logger.debug(exception) logger.info( "Consider saving the password in an environmental variable as " "SN_PSWD.") for _ in range(attempts): password = getpass.getpass() s_note = simplenote.Simplenote(username, password) try: s_note.authenticate(username, password) # Beetlejuice, Beetlejuice, Beetlejuice except simplenote.simplenote.SimplenoteLoginFailed as exception: logger.debug(exception) print("Incorrect password.") else: return s_note raise ValueError("Too many incorrect password attempts.")
import simplenote import json import os # Load and init dotenv from dotenv import load_dotenv, find_dotenv load_dotenv(find_dotenv()) # Init Simplenote API with username and pass from a .env file sn = simplenote.Simplenote(os.environ.get("EMAIL"), os.environ.get("PASS")) # Make sure your google takeout json files are in a "data" folder for filename in os.listdir("./data"): print(filename, type(filename)) # open every file in the folder with open(os.path.join("./data/", filename)) as file: # Load the json data try: data = json.load(file, encoding="utf-8") except: print("couldn't open file") continue # Build the "Note" object to uplaod to simplenote content = "" # Skip empty notes if (len(data["title"]) <= 0 and len(data["textContent"]) <= 0): print("file skipped") continue
import simplenote import json import base64 from itertools import cycle key = 'simplenote' passwd = input("Contraseña Simplenote: ") sn = simplenote.Simplenote("*****@*****.**",passwd) todo=sn.get_note_list(data=True, tags=[]) en_json = json.dumps(todo, indent=4) mensaje = ''.join(chr(ord(c)^ord(k)) for c,k in zip(en_json, cycle(key))) with open('/data/data/com.termux/files/home/pjexposito.github.io/datos.hex', 'wb') as f: f.write(mensaje.encode()) print ("Archivo creado. Subiendo a Github...")
def get_pw(): config = configparser.ConfigParser() config.read('config.ini') returndata = (config['email']['username'], config['email']['password'], config['openweathermap']['apikey'], config['note_email']['user'], config['note_email']['password2']) return returndata username, password, api_key, user, password2 = get_pw() location = 'Oberderdingen' sn = simplenote.Simplenote(user, password2) def get_forecast(api_key, location): url = "https://api.openweathermap.org/data/2.5/forecast?q={}&units=metric&appid={}".format( location, api_key) r = requests.get(url) return r.json() pygame.init() #screen = pygame.display.set_mode((500, 500), 0, 32) screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) backgroundfile = "background.png"
def __init__(self, user, password): self.connector = simplenote.Simplenote(user, password)
def test_simplenote_failed_auth(self): s = simplenote.Simplenote(self.user, "") self.assertRaises(simplenote.SimplenoteLoginFailed, s.get_token)
def fetch_Auth_Data(email, password):#{{{ ''' fetch authdata from the internet. ''' authData = simplenote.Simplenote(email, password) return authData
import simplenote import json from datetime import datetime from dotenv import load_dotenv import os load_dotenv() # loads .env # OR, the same with increased verbosity # load_dotenv(verbose=True) # settings USER = os.getenv("USER") PASSWORD = os.getenv("PASSWORD") sn = simplenote.Simplenote(USER, PASSWORD) def get_note_list(): # listt = sn.get_note_list(data=True, since=cursor, tags=[]) print("GETTING NOTE LIST...") print("--------------------") note_list = sn.get_note_list(data=True, tags=["links"]) notes_json = json.dumps(note_list, indent=4) print(notes_json) with open('notes.json', 'w', encoding='utf-8') as outfile: json.dump(note_list, outfile) get_note_list()
def __init__(self, username, password): self.simplenote = simplenote.Simplenote(username, password) self.note_index = [] self.note_version = {} self.bufnum_to_noteid = {}
import praw import yaml import simplenote number_of_upvotes = 10000 time_filter = 'week' # you can use all, day, hour, month, week, # year (default: all). limit_posts = 20 sn = simplenote.Simplenote("simplenote e-mail", "simplenote password") reddit = praw.Reddit(client_id='', client_secret='', password='', user_agent='', username='') def read_config(): with open('config.yaml', 'r') as f: config = yaml.load(f) return config def write_config(data_to_write): with file("config.yaml", 'w') as f: yaml.dump(data_to_write, f) config = read_config() for submission in reddit.subreddit('lifeprotips').top(time_filter=time_filter, limit=limit_posts):
import sys import simplenote username = os.environ["SIMPLENOTE_USERNAME"] password = os.environ["SIMPLENOTE_PASSWORD"] updated_tag = os.environ["SIMPLENOTE_UPDATED_TAG"] archive_tag = os.environ["SIMPLENOTE_ARCHIVE_TAG"] if not (username and password and updated_tag and archive_tag): print( "Environment variables not found: SIMPLENOTE_USERNAME, SIMPLENOTE_PASSWORD, SIMPLENOTE_UPDATED_TAG, SIMPLENOTE_ARCHIVE_TAG" ) sys.exit(1) sn = simplenote.Simplenote(username, password) def simplenote_archiver(request=None): notes, status = sn.get_note_list(tags=[updated_tag]) notes = filter(lambda x: not x["deleted"], notes) if status: print("Note retrieval failed") sys.exit(1) date_str = str(datetime.datetime.now().date()) for note in notes: sn.add_note({ 'content': date_str + " " + note['content'],
def setUpClass(cls): cls.user = "******" password = "******" cls.simplenote_instance = simplenote.Simplenote(cls.user, password)
def connect(self): self.sn_api = simplenote.Simplenote(self.username, self.password)
import json import os import sys from configparser import ConfigParser import simplenote file_name = sys.argv[1] new_note = json.loads(open(file_name).read()) home = os.path.abspath(os.path.expanduser('~')) cfg_files = [ # os.path.join(app_dir, 'nvpy.cfg'), os.path.join(home, 'nvpy.cfg'), os.path.join(home, '.nvpy.cfg'), os.path.join(home, '.nvpy'), os.path.join(home, '.nvpyrc'), ] cp = ConfigParser() cp.read(cfg_files) user = cp.get('nvpy', 'sn_username', raw=True) passwd = cp.get('nvpy', 'sn_password', raw=True) sn = simplenote.Simplenote(user, passwd) note, status = sn.update_note(new_note) if status == 0: print(json.dumps(note)) else: print(str(note))
import os if __name__ == '__main__': config = configparser.ConfigParser() config_path = os.path.join(os.path.dirname(__file__), '..', 'simpleautonote.conf') if not os.path.exists(config_path): raise FileNotFoundError("Can't find configuration file at %s" % config_path) config.read(config_path) username = config['login']['user'] password = config['login']['password'] inbox_name = config['general']['inbox_name'] if len(inbox_name) == 0: raise RuntimeError("Must get an inbox_name untagged_note") simplenote_client = simplenote.Simplenote(username, password) note_list, status = simplenote_client.get_note_list() if status != 0: raise RuntimeError("Failed to call get_note_list") num_notes_with_tags = 0 num_notes_without_tags = 0 notes_without_tags = [] for note in note_list: if len(note['tags']) == 0 and note.get('deleted', 0) != 1: num_notes_without_tags += 1 notes_without_tags.append(note) else: num_notes_with_tags += 1 print("Found %d notes without tags" % (num_notes_without_tags))