repo stringlengths 2 99 | file stringlengths 13 225 | code stringlengths 0 18.3M | file_length int64 0 18.3M | avg_line_length float64 0 1.36M | max_line_length int64 0 4.26M | extension_type stringclasses 1
value |
|---|---|---|---|---|---|---|
GNNDelete | GNNDelete-main/framework/models/graph_classification/gcn_delete.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ogb.graphproppred.mol_encoder import AtomEncoder
from torch_geometric.nn import GCNConv, MessagePassing, global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set
from ogb.graphproppred.mol_encoder import AtomEncoder, BondEncoder... | 5,857 | 34.719512 | 153 | py |
GNNDelete | GNNDelete-main/framework/models/graph_classification/gcn.py | import torch
import torch.nn as nn
import torch.nn.functional as F
from ogb.graphproppred.mol_encoder import AtomEncoder
from torch_geometric.nn import GCNConv, MessagePassing, global_add_pool, global_mean_pool, global_max_pool, GlobalAttention, Set2Set
from ogb.graphproppred.mol_encoder import AtomEncoder, BondEncoder... | 5,019 | 35.642336 | 153 | py |
Researchers-Migrations | Researchers-Migrations-main/Researchers' migrations study/2 - Data ORCID/ORCID extraction/ORCiD_data_user_remover.py | #name of the output .csv file
filename = 'ORCID_2021_10_activities_2_extract'
new_filename = 'ORCID_2021_10_activities_2_extract_clean'
ids_to_remove = ['0000-0002-2103-7692']
import os, sys
import pandas as pd
#check we are in the right place
print(os.getcwd())
df = pd.read_csv(filename)
for id in ids_to_remove:
... | 378 | 18.947368 | 57 | py |
Researchers-Migrations | Researchers-Migrations-main/Researchers' migrations study/2 - Data ORCID/ORCID extraction/ORCiD_data_file_adder.py | #name of the output .csv file
dataset_name = 'ORCID_2021_10_activities_2_extract'
file_names = ['0000-0002-2103-7692_employments_3086073.xml']
ids = ['0000-0002-2103-7692']
flags = ['EMP']
new_dataset_name = 'ORCID_2021_10_activities_2_extract_final'
import os, sys
import pandas as pd
import copy
import xml.etree.Elem... | 4,166 | 28.553191 | 134 | py |
Researchers-Migrations | Researchers-Migrations-main/Researchers' migrations study/2 - Data ORCID/ORCID extraction/ORCiD_data_extractor_final.py | #folder which contains all folders for groups of IDs
data_dir = 'ORCID_2021_10_activities_2'
#name of the output .csv file
filename = 'ORCID_2021_10_activities_2_extract'
import os, sys
import pandas as pd
import xml.etree.ElementTree as ET
#check we are in the right place
print(os.getcwd())
useful_directories = ['... | 6,472 | 31.527638 | 156 | py |
nixpkgs | nixpkgs-master/pkgs/tools/inputmethods/fcitx5/update.py | #!/usr/bin/env nix-shell
#!nix-shell -i python3 -p nix-update nix-prefetch-github python3Packages.requests
from nix_prefetch_github import *
import requests
import subprocess
REPOS = [
"libime",
"xcb-imdkit",
"fcitx5",
"fcitx5-anthy",
"fcitx5-chewing",
"fcitx5-chinese-... | 1,124 | 24 | 102 | py |
nixpkgs | nixpkgs-master/pkgs/tools/security/enpass/update_script.py | from __future__ import print_function
import argparse
import bz2
import email
import json
import logging
from itertools import product
from operator import itemgetter
import attr
import pkg_resources
from pathlib2 import Path
from requests import Session
from six.moves.urllib_parse import urljoin
@attr.s
class R... | 2,413 | 24.145833 | 77 | py |
nixpkgs | nixpkgs-master/pkgs/tools/X11/xborders/setup.py | from setuptools import setup
setup(
name='@pname@',
version='@version@',
author='deter0',
description='@desc@',
install_requires=['pycairo', 'requests', 'PyGObject'],
scripts=[
'xborders',
],
)
| 231 | 16.846154 | 58 | py |
nixpkgs | nixpkgs-master/pkgs/tools/X11/xkeysnail/browser-emacs-bindings.py | # -*- coding: utf-8 -*-
import re
from xkeysnail.transform import *
aa = False
def aa_setvar(v):
def _aa_setvar():
transform._mark_set = False
global aa; aa = v
return _aa_setvar
def aa_ifvar():
def _aa_ifvar():
transform._mark_set = False
global aa
if aa: aa = False... | 1,622 | 29.055556 | 69 | py |
nixpkgs | nixpkgs-master/pkgs/tools/misc/btdu/update.py | #!/usr/bin/env nix-shell
#!nix-shell -i python -p python39Packages.requests
import requests
import subprocess
pkgbuild = requests.get('https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h=btdu').text
def grabDepVersions(depDict, pkgbuild=pkgbuild):
for line in pkgbuild.split('\n'):
if depDict["string"... | 2,703 | 31.578313 | 106 | py |
nixpkgs | nixpkgs-master/pkgs/tools/admin/google-cloud-sdk/beta__init__.py | # Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 788 | 31.875 | 74 | py |
nixpkgs | nixpkgs-master/pkgs/tools/admin/google-cloud-sdk/alpha__init__.py | # Copyright 2013 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or ag... | 791 | 32 | 74 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_html.py | import nixos_render_docs as nrd
import pytest
import textwrap
from sample_md import sample1
class Renderer(nrd.html.HTMLRenderer):
def _pull_image(self, src: str) -> str:
return src
class Converter(nrd.md.Converter[nrd.html.HTMLRenderer]):
def __init__(self, manpage_urls: dict[str, str], xrefs: dict[... | 8,956 | 33.85214 | 108 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_lists.py | import nixos_render_docs as nrd
import pytest
from markdown_it.token import Token
class Converter(nrd.md.Converter[nrd.docbook.DocBookRenderer]):
# actual renderer doesn't matter, we're just parsing.
def __init__(self, manpage_urls: dict[str, str]) -> None:
super().__init__()
self._renderer = ... | 14,128 | 73.756614 | 112 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_manpage.py | import nixos_render_docs as nrd
from sample_md import sample1
from typing import Mapping
class Converter(nrd.md.Converter[nrd.manpage.ManpageRenderer]):
def __init__(self, manpage_urls: Mapping[str, str], options_by_id: dict[str, str] = {}):
super().__init__()
self._renderer = nrd.manpage.Manpag... | 2,891 | 16.011765 | 94 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_commonmark.py | import nixos_render_docs as nrd
from sample_md import sample1
from typing import Mapping
class Converter(nrd.md.Converter[nrd.commonmark.CommonMarkRenderer]):
def __init__(self, manpage_urls: Mapping[str, str]):
super().__init__()
self._renderer = nrd.commonmark.CommonMarkRenderer(manpage_urls)
... | 1,686 | 15.87 | 98 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/sample_md.py | sample1 = """\
:::: {.warning}
foo
::: {.note}
nested
:::
::::
[
multiline
](link)
{manpage}`man(1)` reference
[some [nested]{#a} anchors]{#b}
*emph* **strong** *nesting emph **and strong** and `code`*
- wide bullet
- list
1. wide ordered
2. list
- narrow bullet
- list
1. narrow ordered
2. list
> quotes
>>... | 605 | 8.619048 | 58 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_asciidoc.py | import nixos_render_docs as nrd
from sample_md import sample1
class Converter(nrd.md.Converter[nrd.asciidoc.AsciiDocRenderer]):
def __init__(self, manpage_urls: dict[str, str]):
super().__init__()
self._renderer = nrd.asciidoc.AsciiDocRenderer(manpage_urls)
def test_lists() -> None:
c = Conve... | 1,555 | 9.657534 | 73 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_plugins.py | import nixos_render_docs as nrd
import pytest
from markdown_it.token import Token
class Converter(nrd.md.Converter[nrd.docbook.DocBookRenderer]):
# actual renderer doesn't matter, we're just parsing.
def __init__(self, manpage_urls: dict[str, str]) -> None:
super().__init__()
self._renderer = ... | 36,568 | 68.128544 | 111 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_headings.py | import nixos_render_docs as nrd
from markdown_it.token import Token
class Converter(nrd.md.Converter[nrd.docbook.DocBookRenderer]):
# actual renderer doesn't matter, we're just parsing.
def __init__(self, manpage_urls: dict[str, str]) -> None:
super().__init__()
self._renderer = nrd.docbook.Do... | 6,423 | 60.180952 | 101 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/tests/test_options.py | import nixos_render_docs
from markdown_it.token import Token
import pytest
def test_option_headings() -> None:
c = nixos_render_docs.options.DocBookConverter({}, 'local', 'none', 'vars', 'opt-')
with pytest.raises(RuntimeError) as exc:
c._render("# foo")
assert exc.value.args[0] == 'md token not s... | 561 | 36.466667 | 95 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/asciidoc.py | from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from typing import cast
from urllib.parse import quote
from .md import Renderer
from markdown_it.token import Token
_asciidoc_escapes = {
# escape all dots, just in case one is pasted at SOL
ord('.'): "{zwsp}.",
# may be repl... | 9,525 | 42.898618 | 104 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual.py | import argparse
import hashlib
import html
import json
import re
import xml.sax.saxutils as xml
from abc import abstractmethod
from collections.abc import Mapping, Sequence
from pathlib import Path
from typing import Any, cast, ClassVar, Generic, get_args, NamedTuple
from markdown_it.token import Token
from . import... | 35,938 | 46.727756 | 122 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/commonmark.py | from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from typing import cast, Optional
from .md import md_escape, md_make_code, Renderer
from markdown_it.token import Token
@dataclass(kw_only=True)
class List:
next_idx: Optional[int] = None
compact: bool
first_item_seen: bool =... | 8,928 | 45.748691 | 94 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/docbook.py | from collections.abc import Mapping, Sequence
from typing import cast, Optional, NamedTuple
from markdown_it.token import Token
from xml.sax.saxutils import escape, quoteattr
from .md import Renderer
_xml_id_translate_table = {
ord('*'): ord('_'),
ord('<'): ord('_'),
ord(' '): ord('_'),
ord('>'): ord... | 12,382 | 48.931452 | 108 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/html.py | from collections.abc import Mapping, Sequence
from typing import cast, Optional, NamedTuple
from html import escape
from markdown_it.token import Token
from .manual_structure import XrefTarget
from .md import Renderer
class UnresolvedXrefError(Exception):
pass
class Heading(NamedTuple):
container_tag: str
... | 17,260 | 47.759887 | 112 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/md.py | from abc import ABC
from collections.abc import Mapping, MutableMapping, Sequence
from typing import Any, Callable, cast, Generic, get_args, Iterable, Literal, NoReturn, Optional, TypeVar
import dataclasses
import re
from .types import RenderFn
import markdown_it
from markdown_it.token import Token
from markdown_it.... | 29,769 | 47.327922 | 105 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/utils.py | from typing import Any
_frozen_classes: dict[type, type] = {}
# make a derived class freezable (ie, disallow modifications).
# we do this by changing the class of an instance at runtime when freeze()
# is called, providing a derived class that is exactly the same except
# for a __setattr__ that raises an error when c... | 923 | 41 | 74 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/types.py | from collections.abc import Sequence
from typing import Callable, Optional, NamedTuple
from markdown_it.token import Token
OptionLoc = str | dict[str, str]
Option = dict[str, str | dict[str, str] | list[OptionLoc]]
class RenderedOption(NamedTuple):
loc: list[str]
lines: list[str]
links: Optional[list[str... | 387 | 24.866667 | 58 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manual_structure.py | from __future__ import annotations
import dataclasses as dc
import html
import itertools
from typing import cast, get_args, Iterable, Literal, Sequence
from markdown_it.token import Token
from .utils import Freezeable
# FragmentType is used to restrict structural include blocks.
FragmentType = Literal['preface', '... | 8,847 | 42.372549 | 110 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/options.py | from __future__ import annotations
import argparse
import html
import json
import xml.sax.saxutils as xml
from abc import abstractmethod
from collections.abc import Mapping, Sequence
from markdown_it.token import Token
from typing import Any, Generic, Optional
from urllib.parse import quote
from . import md
from . ... | 25,072 | 37.633282 | 109 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/manpage.py | from collections.abc import Mapping, Sequence
from dataclasses import dataclass
from typing import cast, Iterable, Optional
import re
from markdown_it.token import Token
from .md import Renderer
# roff(7) says:
#
# > roff documents may contain only graphable 7-bit ASCII characters, the space character,
# > and, in ... | 13,238 | 44.96875 | 95 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/__init__.py | import argparse
import sys
import textwrap
import traceback
from io import StringIO
from pprint import pprint
from . import manual
from . import options
from . import parallel
def pretty_print_exc(e: BaseException, *, _desc_text: str = "error") -> None:
print(f"\x1b[1;31m{_desc_text}:\x1b[0m", file=sys.stderr)
... | 1,891 | 32.785714 | 77 | py |
nixpkgs | nixpkgs-master/pkgs/tools/nix/nixos-render-docs/src/nixos_render_docs/parallel.py | # this module only has to exist because cpython has a global interpreter lock
# and markdown-it is pure python code. ideally we'd just use thread pools, but
# the GIL prohibits this.
import multiprocessing
from typing import Any, Callable, Iterable, Optional, TypeVar
R = TypeVar('R')
S = TypeVar('S')
T = TypeVar('T'... | 2,882 | 47.864407 | 97 | py |
nixpkgs | nixpkgs-master/pkgs/tools/games/minecraft/optifine/update.py | #!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=./. -i python3 -p python3.pkgs.requests python3.pkgs.lxml nix
from lxml import html
import json
import os.path
import re
import requests
import subprocess
def nix_prefetch_sha256(name):
return subprocess.run(['nix-prefetch-url', '--type', 'sha256', 'https://optifine... | 2,253 | 35.95082 | 157 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/docker/stream_layered_image.py | """
This script generates a Docker image from a set of store paths. Uses
Docker Image Specification v1.2 as reference [1].
It expects a JSON file with the following properties and writes the
image as an uncompressed tarball to stdout:
* "architecture", "config", "os", "created", "repo_tag" correspond to
the fields ... | 12,671 | 31.326531 | 128 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/docker/detjson.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Deterministic layer json: https://github.com/docker/hub-feedback/issues/488
import sys
reload(sys)
sys.setdefaultencoding('UTF8')
import json
# If any of the keys below are equal to a certain value
# then we can delete it because it's the default value
SAFEDELS = {
... | 907 | 21.146341 | 77 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/dotnet/make-nuget-source/extract-licenses-from-nupkgs.py | #!/usr/bin/env python3
"""
Opens each .nupkg file in a directory, and extracts the SPDX license identifiers
from them if they exist. The SPDX license identifier is stored in the
'<license type="expression">...</license>' tag in the .nuspec file.
All found license identifiers will be printed to stdout.
"""
from glob im... | 1,062 | 33.290323 | 91 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/templaterpm/nix-template-rpm.py | #!/bin/env python
import sys
import os
import subprocess
import argparse
import re
import shutil
import rpm
import urlparse
import traceback
import toposort
class SPECTemplate(object):
def __init__(self, specFilename, outputDir, inputDir=None, buildRootInclude=None, translateTable=None, repositoryDir=None, allP... | 19,069 | 35.743738 | 322 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/rust/replace-workspace-values.py | # This script implements the workspace inheritance mechanism described
# here: https://doc.rust-lang.org/cargo/reference/workspaces.html#the-package-table
#
# Please run `mypy --strict`, `black`, and `isort --profile black` on this after editing, thanks!
import sys
from typing import Any
import tomli
import tomli_w
... | 3,095 | 27.666667 | 101 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/rust/sysroot/cargo.py | import os
import toml
rust_src = os.environ['RUSTC_SRC']
orig_cargo = os.environ['ORIG_CARGO'] if 'ORIG_CARGO' in os.environ else None
base = {
'package': {
'name': 'nixpkgs-sysroot-stub-crate',
'version': '0.0.0',
'authors': ['The Rust Project Developers'],
'edition': '2018',
},
'dependencies':... | 1,078 | 21.479167 | 77 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/rust/fetch-cargo-tarball/cargo-vendor-normalise.py | #!/usr/bin/env python
import sys
import toml
def quote(s: str) -> str:
escaped = s.replace('"', r"\"").replace("\n", r"\n").replace("\\", "\\\\")
return '"{}"'.format(escaped)
def main() -> None:
data = toml.load(sys.stdin)
# There is no dependency to vendor in this project.
if not list(data.... | 1,095 | 23.909091 | 78 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/binary-cache/make-binary-cache.py |
import json
import os
import subprocess
with open(".attrs.json", "r") as f:
closures = json.load(f)["closure"]
os.chdir(os.environ["out"])
nixPrefix = os.environ["NIX_STORE"] # Usually /nix/store
with open("nix-cache-info", "w") as f:
f.write("StoreDir: " + nixPrefix + "\n")
def dropPrefix(path):
return pat... | 1,329 | 29.227273 | 132 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/replace-secret/replace-secret.py | #!/usr/bin/env python
import argparse
from argparse import RawDescriptionHelpFormatter
description = """
Replace a string in one file with a secret from a second file.
Since the secret is read from a file, it won't be leaked through
'/proc/<pid>/cmdline', unlike when 'sed' or 'replace' is used.
"""
parser = argpars... | 900 | 30.068966 | 74 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/references-by-popularity/closure-graph.py | # IMPORTANT: Making changes?
#
# Validate your changes with python3 ./closure-graph.py --test
# Using a simple algorithm, convert the references to a path in to a
# sorted list of dependent paths based on how often they're referenced
# and how deep in the tree they live. Equally-"popular" paths are then
# sorted by n... | 16,271 | 27.647887 | 98 | py |
nixpkgs | nixpkgs-master/pkgs/build-support/setup-hooks/auto-patchelf.py | #!/usr/bin/env python3
import argparse
import os
import pprint
import subprocess
import sys
from fnmatch import fnmatch
from collections import defaultdict
from contextlib import contextmanager
from dataclasses import dataclass
from itertools import chain
from pathlib import Path, PurePath
from typing import DefaultDi... | 13,424 | 35.480978 | 113 | py |
nixpkgs | nixpkgs-master/pkgs/servers/apache-airflow/update-providers.py | #! /usr/bin/env python3
from itertools import chain
import json
import logging
from pathlib import Path
import os
import re
import subprocess
import sys
from typing import Dict, List, Optional, Set, TextIO
from urllib.request import urlopen
from urllib.error import HTTPError
import yaml
PKG_SET = "apache-airflow.pyth... | 7,642 | 32.52193 | 88 | py |
nixpkgs | nixpkgs-master/pkgs/servers/home-assistant/parse-requirements.py | #! /usr/bin/env nix-shell
#! nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ packaging rich ])" -p nodePackages.pyright ruff isort"
#
# This script downloads Home Assistant's source tarball.
# Inside the homeassistant/components directory, each integration has an associated manifest.json,
# specifying req... | 11,563 | 36.667752 | 119 | py |
nixpkgs | nixpkgs-master/pkgs/servers/home-assistant/update.py | #!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=channel:nixpkgs-unstable -i python3 -p "python3.withPackages (ps: with ps; [ aiohttp packaging ])" -p git nurl nodePackages.pyright ruff isort
import asyncio
import json
import os
import re
import sys
from subprocess import check_output, run
from typing import Dict, Fina... | 8,577 | 31.492424 | 165 | py |
nixpkgs | nixpkgs-master/pkgs/servers/dict/wordnet_structures.py | #!/usr/bin/env python3
#Copyright 2007 Sebastian Hagen
# This file is part of wordnet_tools.
# wordnet_tools is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation
# wordnet_tools is distributed in the hop... | 11,618 | 35.196262 | 212 | py |
nixpkgs | nixpkgs-master/pkgs/servers/dict/wiktionary/latest_version.py | import subprocess
from html.parser import HTMLParser
from os.path import abspath, dirname
from urllib.request import urlopen
class WiktionaryLatestVersionParser(HTMLParser):
def __init__(self, current_version, *args, **kwargs):
self.latest_version = current_version
super().__init__(*args, **kwargs... | 1,145 | 25.651163 | 76 | py |
nixpkgs | nixpkgs-master/pkgs/servers/dict/wiktionary/wiktionary2dict.py | # Adapted to produce DICT-compatible files by Petr Rockai in 2012
# Based on code from wiktiondict by Greg Hewgill
import re
import sys
import os
import textwrap
import time
import xml.sax
class Text:
def __init__(self, s):
self.s = s
def process(self):
return s
class TemplateCall:
def __i... | 24,342 | 30.369845 | 200 | py |
nixpkgs | nixpkgs-master/pkgs/servers/asterisk/update.py | #!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3 python3.pkgs.packaging python3.pkgs.beautifulsoup4 python3.pkgs.requests
# mirrored in ./default.nix
from packaging import version
from bs4 import BeautifulSoup
import re, requests, json
import os, sys
from pathlib import Path
URL = "https://downloads.asterisk... | 1,416 | 32.738095 | 123 | py |
nixpkgs | nixpkgs-master/pkgs/servers/web-apps/lemmy/update.py | #! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 python3.pkgs.semver nix-prefetch-github
from urllib.request import Request, urlopen
import dataclasses
import subprocess
import hashlib
import os.path
import semver
import base64
from typing import (
Optional,
Dict,
List,
)
import json
import os
... | 5,190 | 28.162921 | 91 | py |
nixpkgs | nixpkgs-master/pkgs/servers/web-apps/discourse/update.py | #!/usr/bin/env nix-shell
#! nix-shell -i python3 -p bundix bundler nix-update nix-universal-prefetch python3 python3Packages.requests python3Packages.click python3Packages.click-log prefetch-yarn-deps
from __future__ import annotations
import click
import click_log
import shutil
import tempfile
import re
import loggin... | 16,096 | 35.418552 | 175 | py |
nixpkgs | nixpkgs-master/pkgs/os-specific/linux/freeipa/paths.py | from ipaplatform.fedora.paths import FedoraPathNamespace
class NixOSPathNamespace(FedoraPathNamespace):
SBIN_IPA_JOIN = "@out@/bin/ipa-join"
IPA_GETCERT = "@out@/bin/ipa-getcert"
IPA_RMKEYTAB = "@out@/bin/ipa-rmkeytab"
IPA_GETKEYTAB = "@out@/bin/ipa-getkeytab"
NSUPDATE = "@bind@/bin/nsupdate"
B... | 454 | 31.5 | 56 | py |
nixpkgs | nixpkgs-master/pkgs/os-specific/linux/kernel/update-zen.py | #! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 nix nix-prefetch-git
import fileinput
import json
import os
import sys
import re
import subprocess
from datetime import datetime
from urllib.request import urlopen, Request
def panic(exc):
raise Exception(exc)
DIR = os.path.dirname(os.path.abspath(_... | 4,102 | 32.357724 | 95 | py |
nixpkgs | nixpkgs-master/pkgs/os-specific/linux/kernel/hardened/update.py | #! /usr/bin/env nix-shell
#! nix-shell -i python -p "python3.withPackages (ps: [ps.pygithub])" git gnupg
# This is automatically called by ../update.sh.
from __future__ import annotations
import json
import os
import re
import subprocess
import sys
from dataclasses import dataclass
from pathlib import Path
from temp... | 9,422 | 29.794118 | 109 | py |
nixpkgs | nixpkgs-master/pkgs/os-specific/darwin/gen-frameworks.py | #!/usr/bin/env nix-shell
#!nix-shell -i python -p python3 swiftPackages.swift-unwrapped
"""
Generate a frameworks.nix for a macOS SDK.
You may point this tool at an Xcode bundled SDK, but more ideal is using the
SDK from Nixpkgs. For example:
SDK_PATH="$(nix-build --no-link -A darwin.apple_sdk_11_0.MacOSX-SDK)"
./ge... | 5,101 | 33.472973 | 84 | py |
nixpkgs | nixpkgs-master/pkgs/desktops/gnome/find-latest-version.py | import argparse
import math
import json
import requests
import sys
from enum import Enum
from libversion import Version
from typing import (
Callable,
Iterable,
List,
NamedTuple,
Optional,
Tuple,
TypeVar,
Type,
cast,
)
EnumValue = TypeVar("EnumValue", bound=Enum)
def enum_to_arg(... | 5,123 | 30.054545 | 223 | py |
nixpkgs | nixpkgs-master/pkgs/desktops/gnome/extensions/update-extensions.py | #!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../.. -i python3 -p python3
import base64
import json
import logging
import subprocess
import urllib.error
import urllib.request
from operator import itemgetter
from pathlib import Path
from typing import List, Dict, Optional, Any, Tuple
# We don't want all those ... | 12,080 | 38.740132 | 136 | py |
nixpkgs | nixpkgs-master/pkgs/games/factorio/update.py | #!/usr/bin/env nix-shell
#! nix-shell -i python -p "python3.withPackages (ps: with ps; [ ps.absl-py ps.requests ])" nix
from collections import defaultdict
import copy
from dataclasses import dataclass
import json
import os.path
import subprocess
from typing import Callable, Dict
from absl import app
from absl import... | 7,701 | 39.324607 | 154 | py |
nixpkgs | nixpkgs-master/pkgs/games/minecraft-servers/update.py | #!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3Packages.requests python3Packages.dataclasses-json
import json
from dataclasses import dataclass, field
from datetime import datetime
from pathlib import Path
from typing import Any, Dict, List, Optional
import requests
from dataclasses_json import DataClassJs... | 5,088 | 31.414013 | 88 | py |
nixpkgs | nixpkgs-master/pkgs/applications/version-management/gitlab/update.py | #!/usr/bin/env nix-shell
#! nix-shell -I nixpkgs=../../../.. -i python3 -p bundix bundler nix-update nix nix-universal-prefetch python3 python3Packages.requests python3Packages.click python3Packages.click-log python3Packages.packaging prefetch-yarn-deps git
import click
import click_log
import re
import logging
import... | 11,960 | 30.067532 | 232 | py |
nixpkgs | nixpkgs-master/pkgs/applications/version-management/sapling/gen-deps.py | #!/usr/bin/env nix-shell
#!nix-shell -i python3 -p "python3.withPackages (ps: with ps; [ requests ])"
import json
import re
from hashlib import sha1
from struct import unpack
from subprocess import run
from requests import get
# Fetch the latest stable release metadata from GitHub
latestTag = get("https://api.github.... | 1,383 | 31.186047 | 88 | py |
nixpkgs | nixpkgs-master/pkgs/applications/networking/instant-messengers/discord/disable-breaking-updates.py | #!@pythonInterpreter@
# slightly tweaked from the script created by @lionirdeadman
# https://github.com/flathub/com.discordapp.Discord/blob/master/disable-breaking-updates.py
"""
Disable breaking updates which will prompt users to download a deb or tar file
and lock them out of Discord making the program unusable.
Thi... | 1,677 | 32.56 | 97 | py |
nixpkgs | nixpkgs-master/pkgs/applications/networking/browsers/microsoft-edge/update.py | #! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3Packages.packaging python3Packages.debian
import base64
import gzip
import textwrap
from urllib import request
from debian.deb822 import Packages
from debian.debian_support import Version
def packages():
packages_url = 'https://packages.microsoft.com/r... | 2,191 | 30.768116 | 102 | py |
nixpkgs | nixpkgs-master/pkgs/applications/networking/browsers/chromium/update.py | #! /usr/bin/env nix-shell
#! nix-shell -i python -p python3 nix nix-prefetch-git
"""This script automatically updates chromium, google-chrome, chromedriver, and ungoogled-chromium
via upstream-info.json."""
# Usage: ./update.py [--commit]
import base64
import csv
import json
import re
import subprocess
import sys
fr... | 10,005 | 39.840816 | 154 | py |
nixpkgs | nixpkgs-master/pkgs/applications/networking/browsers/chromium/get-commit-message.py | #!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3Packages.feedparser python3Packages.requests
# This script prints the Git commit message for stable channel updates.
# Usage: ./get-commit-message.py [version]
import re
import sys
import textwrap
from collections import OrderedDict
import feedparser
import ... | 2,037 | 36.740741 | 103 | py |
nixpkgs | nixpkgs-master/pkgs/applications/emulators/retroarch/update_cores.py | #!/usr/bin/env nix-shell
#!nix-shell -I nixpkgs=../../../../ -i python3 -p "python3.withPackages (ps: with ps; [ requests nix-prefetch-github ])" -p "git"
import json
import os
import subprocess
import sys
from pathlib import Path
from concurrent.futures import ThreadPoolExecutor
SCRIPT_PATH = Path(__file__).absolute... | 6,821 | 34.905263 | 129 | py |
nixpkgs | nixpkgs-master/pkgs/applications/office/libreoffice/generate-libreoffice-srcs.py | #!/usr/bin/env python3
"""
Converts the LibreOffice `download.lst` file into a Nix expression.
Requires an environment variable named `downloadList` identifying the path
of the input file, and writes the result to stdout.
todo - Ideally we would move as much as possible into derivation dependencies.
"""
import colle... | 9,070 | 26.571429 | 109 | py |
nixpkgs | nixpkgs-master/pkgs/applications/science/electronics/picoscope/update.py | #!/usr/bin/env nix-shell
#!nix-shell --pure -i python3 -p "python3.withPackages (ps: with ps; [ requests ])"
import json
import os
import requests
import sys
def parse_packages(text):
res = []
for package in resp.text.split("\n\n"):
if not package: continue
pkg = {}
for field in package... | 1,456 | 31.377778 | 123 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/emacs/elisp-packages/manual-packages/tree-sitter-langs/update-defaults.py | #!/usr/bin/env nix-shell
#! nix-shell ../../../../../../../. -i python3 -p python3 -p nix
from os.path import (
dirname,
abspath,
join,
)
from typing import (
List,
Any,
)
import subprocess
import json
import sys
import os
def fmt_grammar(grammar: str) -> str:
return "tree-sitter-" + grammar
... | 1,758 | 22.144737 | 77 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/emacs/elisp-packages/manual-packages/tsc/update.py | #!/usr/bin/env python3
from textwrap import dedent
from os.path import (
abspath,
dirname,
join,
)
from typing import (
Dict,
Any,
)
import subprocess
import tempfile
import json
import sys
import re
import requests
def eval_drv(nixpkgs: str, expr: str) -> Any:
expr = "\n".join(
(
... | 2,899 | 22.387097 | 90 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/jetbrains/update_ides.py | #! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 python3.pkgs.packaging python3.pkgs.requests python3.pkgs.xmltodict
import json
import pathlib
import logging
import requests
import subprocess
import sys
import xmltodict
from packaging import version
updates_url = "https://www.jetbrains.com/updates/updates... | 3,754 | 34.093458 | 124 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/jetbrains/plugins/update_plugins.py | #! /usr/bin/env nix-shell
#! nix-shell -i python3 -p python3 python3.pkgs.requests nix.out
from json import load, dumps
from pathlib import Path
from requests import get
from subprocess import run
from argparse import ArgumentParser
# Token priorities for version checking
# From https://github.com/JetBrains/intellij-... | 11,903 | 29.839378 | 175 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/neovim/update-treesitter-parsers.py | #!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3
import re
import subprocess
from pathlib import Path
parsers = {}
dir = Path(__file__).parent
regex = re.compile(r"^set\(TREESITTER_([A-Z_]+)_(URL|SHA256)\s+([^ \)]+)\s*\)\s*$")
src = subprocess.check_output(
[
"nix-build",
dir.parent.par... | 986 | 20 | 83 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/kakoune/plugins/update.py | #!/usr/bin/env nix-shell
#!nix-shell update-shell.nix -i python3
# format:
# $ nix run nixpkgs.python3Packages.black -c black update.py
# type-check:
# $ nix run nixpkgs.python3Packages.mypy -c mypy update.py
# linted:
# $ nix run nixpkgs.python3Packages.flake8 -c flake8 --ignore E501,E265,E402 update.py
import inspe... | 2,517 | 28.97619 | 112 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/vim/plugins/update.py | #!/usr/bin/env nix-shell
#!nix-shell update-shell.nix -i python3
# format:
# $ nix run nixpkgs.python3Packages.black -c black update.py
# type-check:
# $ nix run nixpkgs.python3Packages.mypy -c mypy update.py
# linted:
# $ nix run nixpkgs.python3Packages.flake8 -c flake8 --ignore E501,E265,E402 update.py
# If you se... | 4,649 | 31.291667 | 142 | py |
nixpkgs | nixpkgs-master/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py | #!/usr/bin/env nix-shell
#!nix-shell update-shell.nix -i python
import json
import subprocess
from concurrent.futures import ThreadPoolExecutor
from os import environ
from os.path import dirname, join
lockfile = json.load(open(join(environ["NVIM_TREESITTER"], "lockfile.json")))
configs = json.loads(
subprocess.c... | 1,738 | 21.294872 | 102 | py |
nixpkgs | nixpkgs-master/pkgs/applications/virtualization/crosvm/update.py | #! /usr/bin/env nix-shell
#! nix-shell -p common-updater-scripts python3
#! nix-shell -i python
import csv
import json
import re
import shlex
import subprocess
from os.path import abspath, dirname, splitext
from urllib.request import urlopen
# CrOS version numbers look like this:
# [<chrome-major-version>.]<tip-build... | 2,340 | 41.563636 | 130 | py |
nixpkgs | nixpkgs-master/pkgs/applications/window-managers/sommelier/update.py | #! /usr/bin/env nix-shell
#! nix-shell -p common-updater-scripts python3
#! nix-shell -i python
import csv
import json
import re
import shlex
import subprocess
from os.path import abspath, dirname, splitext
from urllib.request import urlopen
# CrOS version numbers look like this:
# [<chrome-major-version>.]<tip-build... | 2,572 | 42.610169 | 139 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/parsing/tree-sitter/update_impl.py | from urllib.parse import quote
import json
import subprocess as sub
import os
import sys
from typing import Iterator, Any, Literal, TypedDict, Optional
from tempfile import NamedTemporaryFile
debug: bool = True if os.environ.get("DEBUG", False) else False
Bin = str
args: dict[str, Any] = json.loads(os.environ["ARGS"])... | 6,610 | 28.64574 | 103 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/build-managers/bazel/update-srcDeps.py | #!/usr/bin/env python3
import sys
import json
if len(sys.argv) == 1:
print("usage: ./this-script WORKSPACE", file=sys.stderr)
print("Takes the bazel WORKSPACE file and reads all archives into a json dict (by evaling it as python code)", file=sys.stderr)
print("Hail Eris.", file=sys.stderr)
sys.exit(1)
... | 2,007 | 30.873016 | 131 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/build-managers/bazel/bazel_5/update-srcDeps.py | #!/usr/bin/env python3
import sys
import json
if len(sys.argv) != 2:
print("usage: ./this-script src-deps.json < WORKSPACE", file=sys.stderr)
print("Takes the bazel WORKSPACE file and reads all archives into a json dict (by evaling it as python code)", file=sys.stderr)
print("Hail Eris.", file=sys.stderr)
... | 1,842 | 32.509091 | 131 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/build-managers/bazel/bazel_4/update-srcDeps.py | #!/usr/bin/env python3
import sys
import json
if len(sys.argv) != 2:
print("usage: ./this-script src-deps.json < WORKSPACE", file=sys.stderr)
print("Takes the bazel WORKSPACE file and reads all archives into a json dict (by evaling it as python code)", file=sys.stderr)
print("Hail Eris.", file=sys.stderr)
... | 1,841 | 32.490909 | 131 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/build-managers/bazel/bazel_6/update-srcDeps.py | #!/usr/bin/env python3
import sys
import json
if len(sys.argv) != 2:
print("usage: ./this-script src-deps.json < WORKSPACE", file=sys.stderr)
print("Takes the bazel WORKSPACE file and reads all archives into a json dict (by evaling it as python code)", file=sys.stderr)
print("Hail Eris.", file=sys.stderr)
... | 1,842 | 32.509091 | 131 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/poetry2nix/poetry2nix/fetch_from_legacy.py | # Some repositories (such as Devpi) expose the Pypi legacy API
# (https://warehouse.pypa.io/api-reference/legacy.html).
#
# Note it is not possible to use pip
# https://discuss.python.org/t/pip-download-just-the-source-packages-no-building-no-metadata-etc/4651/12
import os
import sys
import netrc
from urllib.parse imp... | 3,896 | 27.866667 | 104 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/poetry2nix/poetry2nix/hooks/python-requires-patch-hook.py | #!/usr/bin/env python
import ast
import sys
import io
# Python2 compat
if sys.version_info[0] < 3:
FileNotFoundError = IOError
# Python <= 3.8 compat
def astunparse(tree):
# Use bundled unparse by default
if hasattr(ast, "unparse"):
return ast.unparse(tree)
# Use example tool from Python so... | 2,043 | 24.55 | 125 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/poetry2nix/poetry2nix/hooks/pyproject-without-special-deps.py | #!/usr/bin/env python
# Patch out special dependencies (git and path) from a pyproject.toml file
import argparse
import sys
import tomlkit
def main(input, output, fields_to_remove):
data = tomlkit.loads(input.read())
try:
deps = data["tool"]["poetry"]["dependencies"]
except KeyError:
pa... | 1,362 | 23.781818 | 74 | py |
nixpkgs | nixpkgs-master/pkgs/development/tools/poetry2nix/poetry2nix/overrides/shapely-rewrite.py | """
Rewrite libc/library path references to Nix store paths
Nixpkgs uses a normal patch for this but we need to be less
sensitive to changes between versions.
"""
from textwrap import dedent
import sys
import ast
import os
with open(sys.argv[1]) as f:
mod = ast.parse(f.read(), "geos.py")
class LibTransformer(as... | 1,268 | 26 | 87 | py |
nixpkgs | nixpkgs-master/pkgs/development/python-modules/recursive-pth-loader/sitecustomize.py | """Recursively load pth files in site-packages of sys.path
- iterate over sys.path
- check for pth in dirs that end in site-packages
- ignore import statements in pth files
- add dirs listed in pth files right after current sys.path element,
they will be processed in next iteration
"""
import os
import site
import ... | 1,240 | 25.404255 | 68 | py |
nixpkgs | nixpkgs-master/pkgs/development/python-modules/spacy/annotation-test/annotate.py | import pytest
import spacy
en_text = (
"When Sebastian Thrun started working on self-driving cars at "
"Google in 2007, few people outside of the company took him "
"seriously. “I can tell you very senior CEOs of major American "
"car companies would shake my hand and turn away because I wasn’t "
"... | 1,695 | 23.228571 | 82 | py |
nixpkgs | nixpkgs-master/pkgs/development/python-modules/waitress-django/setup.py | #!/usr/bin/env python
from distutils.core import setup
setup( name = "waitress-django"
, version = "1.0.0"
, description = "A waitress WSGI server serving django"
, author = "Bas van Dijk"
, author_email = "[email protected]"
, package_dir = {"" : "src"}
, scripts... | 365 | 27.153846 | 61 | py |
nixpkgs | nixpkgs-master/pkgs/development/python-modules/spacy-transformers/annotation-test/annotate.py | import pytest
import spacy
en_text = (
"When Sebastian Thrun started working on self-driving cars at "
"Google in 2007, few people outside of the company took him "
"seriously. “I can tell you very senior CEOs of major American "
"car companies would shake my hand and turn away because I wasn’t "
"... | 1,706 | 23.385714 | 83 | py |
nixpkgs | nixpkgs-master/pkgs/development/python-modules/bpycv/bpycv-test.py | # based on https://github.com/DIYer22/bpycv/blob/c576e01622d87eb3534f73bf1a5686bd2463de97/example/ycb_demo.py
import bpy
import bpycv
import os
import glob
import random
from pathlib import Path
example_data_dir = os.environ['BPY_EXAMPLE_DATA']
out_dir = Path(os.environ['out'])
out_dir.mkdir(parents=True, exist_ok=Tr... | 2,766 | 33.160494 | 109 | py |
nixpkgs | nixpkgs-master/pkgs/development/interpreters/python/run_setup.py | # -*- coding: utf-8 -*-
import setuptools
import tokenize
__file__='setup.py';
exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\\r\\n', '\\n'), __file__, 'exec'))
| 189 | 20.111111 | 106 | py |
nixpkgs | nixpkgs-master/pkgs/development/interpreters/python/sitecustomize.py | """
This is a Nix-specific module for discovering modules built with Nix.
The module recursively adds paths that are on `NIX_PYTHONPATH` to `sys.path`. In
order to process possible `.pth` files `site.addsitedir` is used.
The paths listed in `PYTHONPATH` are added to `sys.path` afterwards, but they
will be added befor... | 1,659 | 40.5 | 138 | py |
nixpkgs | nixpkgs-master/pkgs/development/interpreters/python/update-python-libraries/update-python-libraries.py | #!/usr/bin/env python3
"""
Update a Python package expression by passing in the `.nix` file, or the directory containing it.
You can pass in multiple files or paths.
You'll likely want to use
``
$ ./update-python-libraries ../../pkgs/development/python-modules/**/default.nix
``
to update all non-pinned libraries in... | 17,659 | 31.050817 | 152 | py |
nixpkgs | nixpkgs-master/pkgs/development/interpreters/python/catch_conflicts/catch_conflicts.py | import pkg_resources
import collections
import sys
do_abort = False
packages = collections.defaultdict(list)
for f in sys.path:
for req in pkg_resources.find_distributions(f):
if req not in packages[req.project_name]:
# some exceptions inside buildPythonPackage
if req.project_name ... | 908 | 28.322581 | 88 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.