Initial commit.
commit
c3e2b3c94e
|
@ -0,0 +1,2 @@
|
||||||
|
scratch
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
* Mobilizon importer
|
||||||
|
|
||||||
|
File importer into mobilizon graphql api.
|
||||||
|
|
||||||
|
** Morganize
|
||||||
|
|
||||||
|
This doesn't really make a lot of sense. I'm working on a script to import
|
||||||
|
events via mobilizon GraphQL api from yaml or json or whatever. Probably yaml.
|
||||||
|
|
||||||
|
** Functionality
|
||||||
|
|
||||||
|
*** Login
|
||||||
|
|
||||||
|
*** Get events
|
||||||
|
|
||||||
|
*** Create event
|
||||||
|
|
||||||
|
- options:
|
||||||
|
- update existing
|
||||||
|
- skip existing
|
||||||
|
|
||||||
|
**** From file
|
||||||
|
|
||||||
|
**** User input
|
||||||
|
|
||||||
|
**** Rss feed
|
||||||
|
|
||||||
|
** Structure
|
||||||
|
|
||||||
|
- python Click library for cli
|
||||||
|
- json
|
||||||
|
- graphql-core https://github.com/graphql-python/graphql-core
|
||||||
|
- https://graphql-core-3.readthedocs.io/en/latest/usage/queries.html
|
||||||
|
|
||||||
|
*** developing in guix
|
|
@ -0,0 +1,10 @@
|
||||||
|
Metadata-Version: 1.0
|
||||||
|
Name: mobili-cli
|
||||||
|
Version: 0.1
|
||||||
|
Summary: UNKNOWN
|
||||||
|
Home-page: UNKNOWN
|
||||||
|
Author: UNKNOWN
|
||||||
|
Author-email: UNKNOWN
|
||||||
|
License: UNKNOWN
|
||||||
|
Description: UNKNOWN
|
||||||
|
Platform: UNKNOWN
|
|
@ -0,0 +1,12 @@
|
||||||
|
setup.py
|
||||||
|
mobili_cli/__init__.py
|
||||||
|
mobili_cli/cli.py
|
||||||
|
mobili_cli.egg-info/PKG-INFO
|
||||||
|
mobili_cli.egg-info/SOURCES.txt
|
||||||
|
mobili_cli.egg-info/dependency_links.txt
|
||||||
|
mobili_cli.egg-info/entry_points.txt
|
||||||
|
mobili_cli.egg-info/requires.txt
|
||||||
|
mobili_cli.egg-info/top_level.txt
|
||||||
|
mobili_cli/commands/__init__.py
|
||||||
|
mobili_cli/commands/cmd_init.py
|
||||||
|
mobili_cli/commands/cmd_status.py
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
|
||||||
|
[console_scripts]
|
||||||
|
mobili_cli=mobili_cli.cli:cli
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
click
|
||||||
|
graphql-core
|
||||||
|
requests
|
|
@ -0,0 +1 @@
|
||||||
|
mobili_cli
|
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,61 @@
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
CONTEXT_SETTINGS = dict(auto_envvar_prefix="COMPLEX")
|
||||||
|
|
||||||
|
|
||||||
|
class Environment:
|
||||||
|
def __init__(self):
|
||||||
|
self.verbose = False
|
||||||
|
self.home = os.getcwd()
|
||||||
|
|
||||||
|
def log(self, msg, *args):
|
||||||
|
"""Logs a message to stderr."""
|
||||||
|
if args:
|
||||||
|
msg %= args
|
||||||
|
click.echo(msg, file=sys.stderr)
|
||||||
|
|
||||||
|
def vlog(self, msg, *args):
|
||||||
|
"""Logs a message to stderr only if verbose is enabled."""
|
||||||
|
if self.verbose:
|
||||||
|
self.log(msg, *args)
|
||||||
|
|
||||||
|
|
||||||
|
pass_environment = click.make_pass_decorator(Environment, ensure=True)
|
||||||
|
cmd_folder = os.path.abspath(os.path.join(os.path.dirname(__file__), "commands"))
|
||||||
|
|
||||||
|
print(cmd_folder)
|
||||||
|
|
||||||
|
class ComplexCLI(click.MultiCommand):
|
||||||
|
def list_commands(self, ctx):
|
||||||
|
rv = []
|
||||||
|
for filename in os.listdir(cmd_folder):
|
||||||
|
if filename.endswith(".py") and filename.startswith("cmd_"):
|
||||||
|
rv.append(filename[4:-3])
|
||||||
|
rv.sort()
|
||||||
|
return rv
|
||||||
|
|
||||||
|
def get_command(self, ctx, name):
|
||||||
|
try:
|
||||||
|
mod = __import__(f"mobili_cli.commands.cmd_{name}", None, None, ["cli"])
|
||||||
|
except ImportError:
|
||||||
|
return
|
||||||
|
return mod.cli
|
||||||
|
|
||||||
|
|
||||||
|
@click.command(cls=ComplexCLI, context_settings=CONTEXT_SETTINGS)
|
||||||
|
@click.option(
|
||||||
|
"--home",
|
||||||
|
type=click.Path(exists=True, file_okay=False, resolve_path=True),
|
||||||
|
help="Changes the folder to operate on.",
|
||||||
|
)
|
||||||
|
@click.option("-v", "--verbose", is_flag=True, help="Enables verbose mode.")
|
||||||
|
@pass_environment
|
||||||
|
def cli(ctx, verbose, home):
|
||||||
|
"""A mobilizon command line interface."""
|
||||||
|
ctx.verbose = verbose
|
||||||
|
if home is not None:
|
||||||
|
ctx.home = home
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,13 @@
|
||||||
|
from mobili_cli.cli import pass_environment
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
@click.command("init", short_help="Initializes a repo.")
|
||||||
|
@click.argument("path", required=False, type=click.Path(resolve_path=True))
|
||||||
|
@pass_environment
|
||||||
|
def cli(ctx, path):
|
||||||
|
"""Initializes a repository."""
|
||||||
|
if path is None:
|
||||||
|
path = ctx.home
|
||||||
|
ctx.log(f"Initialized the repository in {click.format_filename(path)}")
|
|
@ -0,0 +1,11 @@
|
||||||
|
from mobili_cli.cli import pass_environment
|
||||||
|
|
||||||
|
import click
|
||||||
|
|
||||||
|
|
||||||
|
@click.command("status", short_help="Shows file changes.")
|
||||||
|
@pass_environment
|
||||||
|
def cli(ctx):
|
||||||
|
"""Shows file changes in the current working directory."""
|
||||||
|
ctx.log("Changed files: none")
|
||||||
|
ctx.vlog("bla bla bla, debug info")
|
|
@ -0,0 +1,26 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
import sgqlc.endpoint.http import HTTPEndpoint
|
||||||
|
|
||||||
|
|
||||||
|
mutation = """
|
||||||
|
mutation Login($email: String, $password: String!) {
|
||||||
|
login(email: $email, password: $password) {
|
||||||
|
accessToken
|
||||||
|
refreshToken
|
||||||
|
user {
|
||||||
|
id
|
||||||
|
email
|
||||||
|
role
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
|
||||||
|
try:
|
||||||
|
username, password = sys.argv[1:]
|
||||||
|
except ValueError:
|
||||||
|
raise SystemExit('Usage: <username|email> <password>')
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
from setuptools import setup
|
||||||
|
|
||||||
|
setup(
|
||||||
|
name="mobili_cli",
|
||||||
|
version="0.1",
|
||||||
|
packages=["mobili_cli", "mobili_cli.commands"],
|
||||||
|
include_package_data=True,
|
||||||
|
install_requires=["click", "graphql-core", "requests"],
|
||||||
|
entry_points="""
|
||||||
|
[console_scripts]
|
||||||
|
mobili_cli=mobili_cli.cli:cli
|
||||||
|
""",
|
||||||
|
)
|
Loading…
Reference in New Issue