aboutsummaryrefslogtree
summaryrefslogtreecommitdiff
path: root/.ci/pypi-check.py
blob: 1b9c11c42b044eb4a9a28d6ba6ad101d48dbf03d (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env python3


import argparse
import sys
import xmlrpc.client


def main():
    parser = argparse.ArgumentParser(description='PyPI package checker')
    parser.add_argument('package_name', metavar='PACKAGE-NAME')

    parser.add_argument(
        '--pypi-index-url',
        help=('PyPI index URL.'),
        default='https://pypi.python.org/pypi')

    args = parser.parse_args()

    pypi = xmlrpc.client.ServerProxy(args.pypi_index_url)
    releases = pypi.package_releases(args.package_name)

    if releases:
        print(next(iter(sorted(releases, reverse=True))))

    return 0


if __name__ == '__main__':
    sys.exit(main())
{ unsigned char zero[8]; memset(zero, 0, sizeof(zero)); sink(zero, 8 - (len % 8)); } } void writeInt(unsigned int n, Sink & sink) { unsigned char buf[8]; memset(buf, 0, sizeof(buf)); buf[0] = n & 0xff; buf[1] = (n >> 8) & 0xff; buf[2] = (n >> 16) & 0xff; buf[3] = (n >> 24) & 0xff; sink(buf, sizeof(buf)); } void writeLongLong(unsigned long long n, Sink & sink) { unsigned char buf[8]; buf[0] = n & 0xff; buf[1] = (n >> 8) & 0xff; buf[2] = (n >> 16) & 0xff; buf[3] = (n >> 24) & 0xff; buf[4] = (n >> 32) & 0xff; buf[5] = (n >> 40) & 0xff; buf[6] = (n >> 48) & 0xff; buf[7] = (n >> 56) & 0xff; sink(buf, sizeof(buf)); } void writeString(const unsigned char * buf, size_t len, Sink & sink) { writeInt(len, sink); sink(buf, len); writePadding(len, sink); } void writeString(const string & s, Sink & sink) { writeString((const unsigned char *) s.data(), s.size(), sink); } template<class T> void writeStrings(const T & ss, Sink & sink) { writeInt(ss.size(), sink); foreach (typename T::const_iterator, i, ss) writeString(*i, sink); } template void writeStrings(const Paths & ss, Sink & sink); template void writeStrings(const PathSet & ss, Sink & sink); void readPadding(size_t len, Source & source) { if (len % 8) { unsigned char zero[8]; size_t n = 8 - (len % 8); source(zero, n); for (unsigned int i = 0; i < n; i++) if (zero[i]) throw SerialisationError("non-zero padding"); } } unsigned int readInt(Source & source) { unsigned char buf[8]; source(buf, sizeof(buf)); if (buf[4] || buf[5] || buf[6] || buf[7]) throw SerialisationError("implementation cannot deal with > 32-bit integers"); return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); } unsigned long long readLongLong(Source & source) { unsigned char buf[8]; source(buf, sizeof(buf)); return ((unsigned long long) buf[0]) | ((unsigned long long) buf[1] << 8) | ((unsigned long long) buf[2] << 16) | ((unsigned long long) buf[3] << 24) | ((unsigned long long) buf[4] << 32) | ((unsigned long long) buf[5] << 40) | ((unsigned long long) buf[6] << 48) | ((unsigned long long) buf[7] << 56); } size_t readString(unsigned char * buf, size_t max, Source & source) { size_t len = readInt(source); if (len > max) throw Error("string is too long"); source(buf, len); readPadding(len, source); return len; } string readString(Source & source) { size_t len = readInt(source); unsigned char * buf = new unsigned char[len]; AutoDeleteArray<unsigned char> d(buf); source(buf, len); readPadding(len, source); return string((char *) buf, len); } template<class T> T readStrings(Source & source) { unsigned int count = readInt(source); T ss; while (count--) ss.insert(ss.end(), readString(source)); return ss; } template Paths readStrings(Source & source); template PathSet readStrings(Source & source); void StringSink::operator () (const unsigned char * data, size_t len) { static bool warned = false; if (!warned && s.size() > threshold) { warnLargeDump(); warned = true; } s.append((const char *) data, len); } }