org-zotero-export
All checks were successful
CI / Build Packages (default) (push) Successful in 46s
CI / Build Packages (example-a) (push) Successful in 47s
CI / Nix Flake Check (push) Successful in 1m51s
CI / Build Packages (example-b) (push) Successful in 46s
CI / Build Packages (pyzotero) (push) Successful in 51s
CI / Build Packages (pyzotero-cli) (push) Successful in 54s
All checks were successful
CI / Build Packages (default) (push) Successful in 46s
CI / Build Packages (example-a) (push) Successful in 47s
CI / Nix Flake Check (push) Successful in 1m51s
CI / Build Packages (example-b) (push) Successful in 46s
CI / Build Packages (pyzotero) (push) Successful in 51s
CI / Build Packages (pyzotero-cli) (push) Successful in 54s
This commit is contained in:
@@ -3,5 +3,5 @@ let
|
||||
packages = import ../pkgs { pkgs = prev; };
|
||||
in
|
||||
{
|
||||
inherit (packages) example-a example-b pyzotero pyzotero-cli;
|
||||
inherit (packages) example-a example-b pyzotero pyzotero-cli khal-export org-zotero-export;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ let
|
||||
pyzotero-cli = pkgs.callPackage ./pyzotero-cli {
|
||||
pyzotero = self.pyzotero;
|
||||
};
|
||||
khal-export = pkgs.callPackage ./khal-export { };
|
||||
org-zotero-export = pkgs.callPackage ./org-zotero-export { };
|
||||
};
|
||||
in
|
||||
self // { default = self.example-a; }
|
||||
|
||||
33
pkgs/khal-export/default.nix
Normal file
33
pkgs/khal-export/default.nix
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
lib,
|
||||
khal,
|
||||
python3Packages,
|
||||
}:
|
||||
|
||||
python3Packages.buildPythonApplication {
|
||||
pname = "khal-export";
|
||||
version = "0.1.0";
|
||||
format = "other";
|
||||
|
||||
src = ./.;
|
||||
|
||||
dontUnpack = true;
|
||||
dontBuild = true;
|
||||
|
||||
propagatedBuildInputs = [
|
||||
khal
|
||||
python3Packages.click
|
||||
python3Packages.icalendar
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
install -Dm755 ${./khal-export.py} $out/bin/khal-export
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Export multiple events from khal in .ics format";
|
||||
platforms = lib.platforms.all;
|
||||
mainProgram = "khal-export";
|
||||
};
|
||||
}
|
||||
36
pkgs/khal-export/khal-export.py
Normal file
36
pkgs/khal-export/khal-export.py
Normal file
@@ -0,0 +1,36 @@
|
||||
#!/usr/bin/env python3
|
||||
from datetime import datetime
|
||||
|
||||
import click
|
||||
from khal.settings import get_config
|
||||
from khal.cli import build_collection
|
||||
from icalendar import Calendar
|
||||
|
||||
|
||||
@click.command()
|
||||
@click.option('--search', 'search_string')
|
||||
@click.option('--allow-past/--future-only', default=False)
|
||||
def main(search_string, allow_past):
|
||||
conf = get_config(None)
|
||||
collection = build_collection(conf, None)
|
||||
now = conf['locale']['local_timezone'].localize(datetime.now())
|
||||
|
||||
vevents = [
|
||||
Calendar.from_ical(event.raw)
|
||||
for event in sorted(collection.search(search_string))
|
||||
if (
|
||||
allow_past
|
||||
or event.allday and event.end >= now.date()
|
||||
or not event.allday and event.end_local >= now
|
||||
)
|
||||
]
|
||||
event_collection = Calendar(next(iter(vevents), {}))
|
||||
for event in vevents:
|
||||
for component in event.subcomponents:
|
||||
event_collection.add_component(component)
|
||||
|
||||
click.echo(event_collection.to_ical())
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
36
pkgs/org-zotero-export/default.nix
Normal file
36
pkgs/org-zotero-export/default.nix
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
python3,
|
||||
pandoc,
|
||||
makeWrapper,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation {
|
||||
pname = "org-zotero-export";
|
||||
version = "0.1.0";
|
||||
|
||||
src = ./.;
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
substitute ${./org-zotero-export.py} $out/bin/org-zotero-export \
|
||||
--replace-fail "#!/usr/bin/env python3" "#!${python3}/bin/python3"
|
||||
chmod +x $out/bin/org-zotero-export
|
||||
'';
|
||||
|
||||
postFixup = ''
|
||||
wrapProgram $out/bin/org-zotero-export \
|
||||
--prefix PATH : ${lib.makeBinPath [ pandoc ]}
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Export Org-mode files to HTML with Zotero Better BibTeX citation links";
|
||||
license = lib.licenses.mit;
|
||||
platforms = lib.platforms.all;
|
||||
};
|
||||
}
|
||||
1019
pkgs/org-zotero-export/org-zotero-export.py
Normal file
1019
pkgs/org-zotero-export/org-zotero-export.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user