mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-26 14:06:15 +01:00
py: Various flake8 cleanups
None of these are particularly significant, but they do get the CI output clean. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
e187d836ad
commit
d270b6c3db
@ -53,7 +53,7 @@ def main():
|
||||
|
||||
for line in log_lines:
|
||||
for keyword in BANNED_KEYWORDS:
|
||||
if re.search("(^|\W+){}(\W+|$)".format(keyword), line):
|
||||
if re.search(r"(^|\W+){}(\W+|$)".format(keyword), line):
|
||||
banned_words_seen.add(keyword)
|
||||
seen_in_log = True
|
||||
|
||||
@ -72,7 +72,7 @@ def main():
|
||||
continue
|
||||
|
||||
for keyword in BANNED_KEYWORDS:
|
||||
if re.search("(^|\W+){}(\W+|$)".format(keyword), line):
|
||||
if re.search(r"(^|\W+){}(\W+|$)".format(keyword), line):
|
||||
banned_words_seen.add(keyword)
|
||||
seen_in_diff = True
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
import argparse
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
#
|
||||
# Author: Xavier Claessens <xavier.claessens@collabora.com>
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
if len(sys.argv) < 3:
|
||||
|
@ -21,8 +21,6 @@
|
||||
#
|
||||
# Author: David Zeuthen <davidz@redhat.com>
|
||||
|
||||
import sys
|
||||
|
||||
from . import config
|
||||
from . import utils
|
||||
from . import dbustypes
|
||||
@ -37,6 +35,10 @@ LICENSE_STR = """/*
|
||||
*/\n"""
|
||||
|
||||
|
||||
# Disable line length warnings as wrapping the C code templates would be hard
|
||||
# flake8: noqa: E501
|
||||
|
||||
|
||||
def generate_namespace(namespace):
|
||||
ns = namespace
|
||||
if len(namespace) > 0:
|
||||
@ -163,7 +165,7 @@ class HeaderCodeGenerator:
|
||||
key = (m.since, "_method_%s" % m.name_lower)
|
||||
value = " gboolean (*handle_%s) (\n" % (m.name_lower)
|
||||
value += " %s *object,\n" % (i.camel_name)
|
||||
value += " GDBusMethodInvocation *invocation" % ()
|
||||
value += " GDBusMethodInvocation *invocation"
|
||||
if m.unix_fd:
|
||||
value += ",\n GUnixFDList *fd_list"
|
||||
for a in m.in_args:
|
||||
@ -369,7 +371,7 @@ class HeaderCodeGenerator:
|
||||
"%s%s_get_%s (%s *object);\n"
|
||||
% (p.arg.ctype_in, i.name_lower, p.name_lower, i.camel_name)
|
||||
)
|
||||
if p.arg.free_func != None:
|
||||
if p.arg.free_func is not None:
|
||||
if self.symbol_decorator is not None:
|
||||
self.outfile.write("%s\n" % self.symbol_decorator)
|
||||
if p.deprecated:
|
||||
@ -2342,7 +2344,7 @@ class CodeGenerator:
|
||||
False,
|
||||
)
|
||||
)
|
||||
if p.arg.free_func != None:
|
||||
if p.arg.free_func is not None:
|
||||
self.outfile.write(
|
||||
" * The returned value is only valid until the property changes so on the client-side it is only safe to use this function on the thread where @object was constructed. Use %s_dup_%s() if on another thread.\n"
|
||||
" *\n"
|
||||
@ -2363,7 +2365,7 @@ class CodeGenerator:
|
||||
)
|
||||
self.outfile.write("}\n")
|
||||
self.outfile.write("\n")
|
||||
if p.arg.free_func != None:
|
||||
if p.arg.free_func is not None:
|
||||
|
||||
self.outfile.write(
|
||||
self.docbook_gen.expand(
|
||||
@ -3082,7 +3084,7 @@ class CodeGenerator:
|
||||
# property vfuncs
|
||||
for p in i.properties:
|
||||
nul_value = "0"
|
||||
if p.arg.free_func != None:
|
||||
if p.arg.free_func is not None:
|
||||
nul_value = "NULL"
|
||||
self.outfile.write(
|
||||
"static %s\n"
|
||||
@ -3544,7 +3546,7 @@ class CodeGenerator:
|
||||
)
|
||||
self.outfile.write(
|
||||
" info = (_ExtendedGDBusMethodInfo *) g_dbus_method_invocation_get_method_info (invocation);\n"
|
||||
" g_assert (info != NULL);\n" % ()
|
||||
" g_assert (info != NULL);\n"
|
||||
)
|
||||
self.outfile.write(
|
||||
" num_params = g_variant_n_children (parameters);\n"
|
||||
@ -4006,7 +4008,7 @@ class CodeGenerator:
|
||||
" g_value_copy (orig_value, &cp->orig_value);\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n" % ()
|
||||
"\n"
|
||||
)
|
||||
|
||||
# Postpone setting up the refresh source until the ::notify signal is emitted as
|
||||
@ -4506,7 +4508,7 @@ class CodeGenerator:
|
||||
" G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);\n"
|
||||
% (self.ns_lower)
|
||||
)
|
||||
self.outfile.write("}\n" "\n" % ())
|
||||
self.outfile.write("}\n" "\n")
|
||||
self.outfile.write(
|
||||
"static void\n"
|
||||
"%sobject_proxy_get_property (GObject *gobject,\n"
|
||||
@ -4536,7 +4538,7 @@ class CodeGenerator:
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n" % ()
|
||||
"\n"
|
||||
)
|
||||
self.outfile.write(
|
||||
"static void\n"
|
||||
@ -4685,7 +4687,7 @@ class CodeGenerator:
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n" % ()
|
||||
"\n"
|
||||
)
|
||||
self.outfile.write(
|
||||
"static void\n"
|
||||
@ -4716,7 +4718,7 @@ class CodeGenerator:
|
||||
" break;\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n" % ()
|
||||
"\n"
|
||||
)
|
||||
self.outfile.write(
|
||||
"static void\n"
|
||||
|
@ -19,14 +19,15 @@
|
||||
#
|
||||
# Author: David Zeuthen <davidz@redhat.com>
|
||||
|
||||
import sys
|
||||
import re
|
||||
from os import path
|
||||
|
||||
from . import config
|
||||
from . import utils
|
||||
from . import dbustypes
|
||||
from . import parser
|
||||
|
||||
|
||||
# Disable line length warnings as wrapping the Docbook templates would be hard
|
||||
# flake8: noqa: E501
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------------
|
||||
|
||||
@ -167,31 +168,31 @@ class DocbookCodeGenerator:
|
||||
self.out.write(" %s %s\n" % (access, p.signature))
|
||||
|
||||
def print_synopsis_methods(self, i):
|
||||
self.out.write(' <refsynopsisdiv role="synopsis">\n' % ())
|
||||
self.out.write(' <title role="synopsis.title">Methods</title>\n' % ())
|
||||
self.out.write(" <synopsis>\n" % ())
|
||||
self.out.write(' <refsynopsisdiv role="synopsis">\n')
|
||||
self.out.write(' <title role="synopsis.title">Methods</title>\n')
|
||||
self.out.write(" <synopsis>\n")
|
||||
for m in i.methods:
|
||||
self.print_method_prototype(i, m, in_synopsis=True)
|
||||
self.out.write("</synopsis>\n" % ())
|
||||
self.out.write(" </refsynopsisdiv>\n" % ())
|
||||
self.out.write("</synopsis>\n")
|
||||
self.out.write(" </refsynopsisdiv>\n")
|
||||
|
||||
def print_synopsis_signals(self, i):
|
||||
self.out.write(' <refsect1 role="signal_proto">\n' % ())
|
||||
self.out.write(' <title role="signal_proto.title">Signals</title>\n' % ())
|
||||
self.out.write(" <synopsis>\n" % ())
|
||||
self.out.write(' <refsect1 role="signal_proto">\n')
|
||||
self.out.write(' <title role="signal_proto.title">Signals</title>\n')
|
||||
self.out.write(" <synopsis>\n")
|
||||
for s in i.signals:
|
||||
self.print_signal_prototype(i, s, in_synopsis=True)
|
||||
self.out.write("</synopsis>\n" % ())
|
||||
self.out.write(" </refsect1>\n" % ())
|
||||
self.out.write("</synopsis>\n")
|
||||
self.out.write(" </refsect1>\n")
|
||||
|
||||
def print_synopsis_properties(self, i):
|
||||
self.out.write(' <refsect1 role="properties">\n' % ())
|
||||
self.out.write(' <title role="properties.title">Properties</title>\n' % ())
|
||||
self.out.write(" <synopsis>\n" % ())
|
||||
self.out.write(' <refsect1 role="properties">\n')
|
||||
self.out.write(' <title role="properties.title">Properties</title>\n')
|
||||
self.out.write(" <synopsis>\n")
|
||||
for p in i.properties:
|
||||
self.print_property_prototype(i, p, in_synopsis=True)
|
||||
self.out.write("</synopsis>\n" % ())
|
||||
self.out.write(" </refsect1>\n" % ())
|
||||
self.out.write("</synopsis>\n")
|
||||
self.out.write(" </refsect1>\n")
|
||||
|
||||
def print_method(self, i, m):
|
||||
self.out.write(
|
||||
@ -217,7 +218,7 @@ class DocbookCodeGenerator:
|
||||
if m.in_args or m.out_args:
|
||||
self.out.write('<variablelist role="params">\n')
|
||||
for a in m.in_args:
|
||||
self.out.write("<varlistentry>\n" % ())
|
||||
self.out.write("<varlistentry>\n")
|
||||
self.out.write(
|
||||
" <term><literal>IN %s <parameter>%s</parameter></literal>:</term>\n"
|
||||
% (a.signature, a.name)
|
||||
@ -226,9 +227,9 @@ class DocbookCodeGenerator:
|
||||
" <listitem>%s</listitem>\n"
|
||||
% (self.expand_paras(a.doc_string, True))
|
||||
)
|
||||
self.out.write("</varlistentry>\n" % ())
|
||||
self.out.write("</varlistentry>\n")
|
||||
for a in m.out_args:
|
||||
self.out.write("<varlistentry>\n" % ())
|
||||
self.out.write("<varlistentry>\n")
|
||||
self.out.write(
|
||||
" <term><literal>OUT %s <parameter>%s</parameter></literal>:</term>\n"
|
||||
% (a.signature, a.name)
|
||||
@ -237,7 +238,7 @@ class DocbookCodeGenerator:
|
||||
" <listitem>%s</listitem>\n"
|
||||
% (self.expand_paras(a.doc_string, True))
|
||||
)
|
||||
self.out.write("</varlistentry>\n" % ())
|
||||
self.out.write("</varlistentry>\n")
|
||||
self.out.write("</variablelist>\n")
|
||||
if len(m.since) > 0:
|
||||
self.out.write('<para role="since">Since %s</para>\n' % (m.since))
|
||||
@ -272,7 +273,7 @@ class DocbookCodeGenerator:
|
||||
if s.args:
|
||||
self.out.write('<variablelist role="params">\n')
|
||||
for a in s.args:
|
||||
self.out.write("<varlistentry>\n" % ())
|
||||
self.out.write("<varlistentry>\n")
|
||||
self.out.write(
|
||||
" <term><literal>%s <parameter>%s</parameter></literal>:</term>\n"
|
||||
% (a.signature, a.name)
|
||||
@ -281,7 +282,7 @@ class DocbookCodeGenerator:
|
||||
" <listitem>%s</listitem>\n"
|
||||
% (self.expand_paras(a.doc_string, True))
|
||||
)
|
||||
self.out.write("</varlistentry>\n" % ())
|
||||
self.out.write("</varlistentry>\n")
|
||||
self.out.write("</variablelist>\n")
|
||||
if len(s.since) > 0:
|
||||
self.out.write('<para role="since">Since %s</para>\n' % (s.since))
|
||||
@ -394,19 +395,17 @@ class DocbookCodeGenerator:
|
||||
def generate(self, docbook, outdir):
|
||||
for i in self.ifaces:
|
||||
self.out = open(path.join(outdir, "%s-%s.xml" % (docbook, i.name)), "w")
|
||||
self.out.write("" % ())
|
||||
self.out.write('<?xml version="1.0" encoding="utf-8"?>\n' % ())
|
||||
self.out.write("")
|
||||
self.out.write('<?xml version="1.0" encoding="utf-8"?>\n')
|
||||
self.out.write(
|
||||
'<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"\n'
|
||||
% ()
|
||||
)
|
||||
self.out.write(
|
||||
' "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [\n'
|
||||
% ()
|
||||
)
|
||||
self.out.write("]>\n" % ())
|
||||
self.out.write("]>\n")
|
||||
self.out.write('<refentry id="gdbus-%s">\n' % (i.name))
|
||||
self.out.write(" <refmeta>" % ())
|
||||
self.out.write(" <refmeta>")
|
||||
self.out.write(
|
||||
' <refentrytitle role="top_of_page" id="gdbus-interface-%s.top_of_page">%s</refentrytitle>\n'
|
||||
% (utils.dots_to_hyphens(i.name), i.name)
|
||||
@ -415,12 +414,12 @@ class DocbookCodeGenerator:
|
||||
' <indexterm zone="gdbus-interface-%s.top_of_page"><primary sortas="%s">%s</primary></indexterm>\n'
|
||||
% (utils.dots_to_hyphens(i.name), i.name_without_prefix, i.name)
|
||||
)
|
||||
self.out.write(" </refmeta>" % ())
|
||||
self.out.write(" </refmeta>")
|
||||
|
||||
self.out.write(" <refnamediv>" % ())
|
||||
self.out.write(" <refnamediv>")
|
||||
self.out.write(" <refname>%s</refname>" % (i.name))
|
||||
self.out.write(" <refpurpose>%s</refpurpose>" % (i.doc_string_brief))
|
||||
self.out.write(" </refnamediv>" % ())
|
||||
self.out.write(" </refnamediv>")
|
||||
|
||||
if len(i.methods) > 0:
|
||||
self.print_synopsis_methods(i)
|
||||
@ -433,7 +432,7 @@ class DocbookCodeGenerator:
|
||||
'<refsect1 role="desc" id="gdbus-interface-%s">\n'
|
||||
% (utils.dots_to_hyphens(i.name))
|
||||
)
|
||||
self.out.write(' <title role="desc.title">Description</title>\n' % ())
|
||||
self.out.write(' <title role="desc.title">Description</title>\n')
|
||||
self.out.write(" %s\n" % (self.expand_paras(i.doc_string, True)))
|
||||
if len(i.since) > 0:
|
||||
self.out.write(' <para role="since">Since %s</para>\n' % (i.since))
|
||||
@ -442,40 +441,36 @@ class DocbookCodeGenerator:
|
||||
"<warning><para>The %s interface is deprecated.</para></warning>"
|
||||
% (i.name)
|
||||
)
|
||||
self.out.write("</refsect1>\n" % ())
|
||||
self.out.write("</refsect1>\n")
|
||||
|
||||
if len(i.methods) > 0:
|
||||
self.out.write(
|
||||
'<refsect1 role="details" id="gdbus-methods-%s">\n' % (i.name)
|
||||
)
|
||||
self.out.write(
|
||||
' <title role="details.title">Method Details</title>\n' % ()
|
||||
)
|
||||
self.out.write(' <title role="details.title">Method Details</title>\n')
|
||||
for m in i.methods:
|
||||
self.print_method(i, m)
|
||||
self.out.write("</refsect1>\n" % ())
|
||||
self.out.write("</refsect1>\n")
|
||||
|
||||
if len(i.signals) > 0:
|
||||
self.out.write(
|
||||
'<refsect1 role="details" id="gdbus-signals-%s">\n' % (i.name)
|
||||
)
|
||||
self.out.write(
|
||||
' <title role="details.title">Signal Details</title>\n' % ()
|
||||
)
|
||||
self.out.write(' <title role="details.title">Signal Details</title>\n')
|
||||
for s in i.signals:
|
||||
self.print_signal(i, s)
|
||||
self.out.write("</refsect1>\n" % ())
|
||||
self.out.write("</refsect1>\n")
|
||||
|
||||
if len(i.properties) > 0:
|
||||
self.out.write(
|
||||
'<refsect1 role="details" id="gdbus-properties-%s">\n' % (i.name)
|
||||
)
|
||||
self.out.write(
|
||||
' <title role="details.title">Property Details</title>\n' % ()
|
||||
' <title role="details.title">Property Details</title>\n'
|
||||
)
|
||||
for s in i.properties:
|
||||
self.print_property(i, s)
|
||||
self.out.write("</refsect1>\n" % ())
|
||||
self.out.write("</refsect1>\n")
|
||||
|
||||
self.out.write("</refentry>\n")
|
||||
self.out.write("\n")
|
||||
|
@ -226,24 +226,29 @@ def codegen_main():
|
||||
arg_parser.add_argument(
|
||||
"--glib-min-required",
|
||||
metavar="VERSION",
|
||||
help="Minimum version of GLib to be supported by the outputted code (default: 2.30)",
|
||||
help="Minimum version of GLib to be supported by the outputted code "
|
||||
"(default: 2.30)",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--glib-max-allowed",
|
||||
metavar="VERSION",
|
||||
help="Maximum version of GLib to be used by the outputted code (default: current GLib version)",
|
||||
help="Maximum version of GLib to be used by the outputted code "
|
||||
"(default: current GLib version)",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--symbol-decorator",
|
||||
help="Macro used to decorate a symbol in the outputted header, possibly to export symbols",
|
||||
help="Macro used to decorate a symbol in the outputted header, "
|
||||
"possibly to export symbols",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--symbol-decorator-header",
|
||||
help="Additional header required for decorator specified by --symbol-decorator",
|
||||
help="Additional header required for decorator specified by "
|
||||
"--symbol-decorator",
|
||||
)
|
||||
arg_parser.add_argument(
|
||||
"--symbol-decorator-define",
|
||||
help="Additional define required for decorator specified by --symbol-decorator",
|
||||
help="Additional define required for decorator specified by "
|
||||
"--symbol-decorator",
|
||||
)
|
||||
|
||||
group = arg_parser.add_mutually_exclusive_group()
|
||||
@ -370,11 +375,13 @@ def codegen_main():
|
||||
else:
|
||||
glib_max_allowed = (config.MAJOR_VERSION, config.MINOR_VERSION)
|
||||
|
||||
# Only allow --symbol-decorator-define and --symbol-decorator-header if --symbol-decorator is used
|
||||
# Only allow --symbol-decorator-define and --symbol-decorator-header if
|
||||
# --symbol-decorator is used
|
||||
if args.symbol_decorator is None:
|
||||
if args.symbol_decorator_header or args.symbol_decorator_define:
|
||||
print_error(
|
||||
"--symbol-decorator-define and --symbol-decorator-header must be used with --symbol-decorator"
|
||||
"--symbol-decorator-define and --symbol-decorator-header must "
|
||||
"be used with --symbol-decorator"
|
||||
)
|
||||
|
||||
# Round --glib-max-allowed up to the next stable release.
|
||||
@ -411,7 +418,7 @@ def codegen_main():
|
||||
docbook = args.generate_docbook
|
||||
docbook_gen = codegen_docbook.DocbookCodeGenerator(all_ifaces)
|
||||
if docbook:
|
||||
ret = docbook_gen.generate(docbook, args.output_directory)
|
||||
docbook_gen.generate(docbook, args.output_directory)
|
||||
|
||||
if args.header:
|
||||
with open(h_file, "w") as outfile:
|
||||
|
@ -414,7 +414,8 @@ class Property:
|
||||
name = overridden_name
|
||||
self.name_lower = utils.camel_case_to_uscore(name).lower().replace("-", "_")
|
||||
self.name_hyphen = self.name_lower.replace("_", "-")
|
||||
# don't clash with the GType getter, e.g.: GType foo_bar_get_type (void); G_GNUC_CONST
|
||||
# don't clash with the GType getter, e.g.:
|
||||
# GType foo_bar_get_type (void); G_GNUC_CONST
|
||||
if self.name_lower == "type":
|
||||
self.name_lower = "type_"
|
||||
|
||||
@ -431,7 +432,8 @@ class Property:
|
||||
for a in self.annotations:
|
||||
a.post_process(interface_prefix, cns, cns_upper, cns_lower, self)
|
||||
|
||||
# FIXME: for now we only support 'false' and 'const' on the signal itself, see #674913 and
|
||||
# FIXME: for now we only support 'false' and 'const' on the signal itself,
|
||||
# see #674913 and
|
||||
# http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format
|
||||
# for details
|
||||
if utils.lookup_annotation(
|
||||
|
@ -19,7 +19,6 @@
|
||||
#
|
||||
# Author: David Zeuthen <davidz@redhat.com>
|
||||
|
||||
import sys
|
||||
import xml.parsers.expat
|
||||
|
||||
from . import dbustypes
|
||||
@ -222,7 +221,7 @@ class DBusXMLParser:
|
||||
if self.doc_comment_last_symbol == old_cur_object.name:
|
||||
if "name" in attrs and attrs["name"] in self.doc_comment_params:
|
||||
doc_string = self.doc_comment_params[attrs["name"]]
|
||||
if doc_string != None:
|
||||
if doc_string is not None:
|
||||
self._cur_object.doc_string = doc_string
|
||||
if "since" in self.doc_comment_params:
|
||||
self._cur_object.since = self.doc_comment_params[
|
||||
@ -250,7 +249,7 @@ class DBusXMLParser:
|
||||
if self.doc_comment_last_symbol == old_cur_object.name:
|
||||
if "name" in attrs and attrs["name"] in self.doc_comment_params:
|
||||
doc_string = self.doc_comment_params[attrs["name"]]
|
||||
if doc_string != None:
|
||||
if doc_string is not None:
|
||||
self._cur_object.doc_string = doc_string
|
||||
if "since" in self.doc_comment_params:
|
||||
self._cur_object.since = self.doc_comment_params[
|
||||
|
@ -23,6 +23,7 @@ import distutils.version
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
# pylint: disable=too-few-public-methods
|
||||
class Color:
|
||||
"""ANSI Terminal colors"""
|
||||
|
@ -26,12 +26,15 @@ import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
import unittest
|
||||
|
||||
import taptestrunner
|
||||
|
||||
|
||||
# Disable line length warnings as wrapping the C code templates would be hard
|
||||
# flake8: noqa: E501
|
||||
|
||||
|
||||
Result = collections.namedtuple("Result", ("info", "out", "err", "subs"))
|
||||
|
||||
|
||||
|
@ -8,7 +8,6 @@
|
||||
#
|
||||
# See issue #1580
|
||||
|
||||
import io
|
||||
import string
|
||||
import sys
|
||||
|
||||
|
@ -29,7 +29,7 @@ for filename in in_files:
|
||||
match = re.search(b"\bg_[a-zA-Z0-9_]*_get_type\b", line)
|
||||
if match:
|
||||
func = match.group(0)
|
||||
if not func in funcs:
|
||||
if func not in funcs:
|
||||
funcs.append(func)
|
||||
if debug:
|
||||
print("Found ", func)
|
||||
|
@ -23,7 +23,7 @@ import sys
|
||||
import tempfile
|
||||
import subprocess
|
||||
|
||||
if not "GLIB_TEST_COMPILATION" in os.environ:
|
||||
if "GLIB_TEST_COMPILATION" not in os.environ:
|
||||
print(
|
||||
"""Test disabled because GLIB_TEST_COMPILATION is not set in the env.
|
||||
If you wish to run this test, set GLIB_TEST_COMPILATION=1 in the env,
|
||||
|
@ -30,6 +30,7 @@ import sys
|
||||
import base64
|
||||
from io import StringIO
|
||||
|
||||
|
||||
# Log modes
|
||||
class LogMode(object):
|
||||
LogToError, LogToDiagnostics, LogToYAML, LogToAttachment = range(4)
|
||||
|
@ -4,6 +4,7 @@ import sys
|
||||
if sys.version_info[0] >= 3:
|
||||
long = int
|
||||
|
||||
|
||||
# This is not quite right, as local vars may override symname
|
||||
def read_global_var(symname):
|
||||
return gdb.selected_frame().read_var(symname)
|
||||
@ -18,11 +19,11 @@ def g_quark_to_string(quark):
|
||||
try:
|
||||
val = read_global_var("quarks")
|
||||
max_q = long(read_global_var("quark_seq_id"))
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
val = read_global_var("g_quarks")
|
||||
max_q = long(read_global_var("g_quark_seq_id"))
|
||||
except:
|
||||
except Exception:
|
||||
return None
|
||||
if quark < max_q:
|
||||
return val[quark].string()
|
||||
@ -130,7 +131,7 @@ class GHashPrinter:
|
||||
def next(self):
|
||||
if self.ht == 0:
|
||||
raise StopIteration
|
||||
if self.value != None:
|
||||
if self.value is not None:
|
||||
v = self.value
|
||||
self.value = None
|
||||
return v
|
||||
@ -160,11 +161,11 @@ class GHashPrinter:
|
||||
self.keys_are_strings = False
|
||||
try:
|
||||
string_hash = read_global_var("g_str_hash")
|
||||
except:
|
||||
except Exception:
|
||||
string_hash = None
|
||||
if (
|
||||
self.val != 0
|
||||
and string_hash != None
|
||||
and string_hash is not None
|
||||
and self.val["hash_func"] == string_hash
|
||||
):
|
||||
self.keys_are_strings = True
|
||||
@ -267,16 +268,16 @@ class ForeachCommand(gdb.Command):
|
||||
gdb.execute(command)
|
||||
|
||||
def slist_iterator(self, arg, container, command):
|
||||
l = container.cast(gdb.lookup_type("GSList").pointer())
|
||||
while long(l) != 0:
|
||||
self.do_iter(arg, l["data"], command)
|
||||
l = l["next"]
|
||||
list_element = container.cast(gdb.lookup_type("GSList").pointer())
|
||||
while long(list_element) != 0:
|
||||
self.do_iter(arg, list_element["data"], command)
|
||||
list_element = list_element["next"]
|
||||
|
||||
def list_iterator(self, arg, container, command):
|
||||
l = container.cast(gdb.lookup_type("GList").pointer())
|
||||
while long(l) != 0:
|
||||
self.do_iter(arg, l["data"], command)
|
||||
l = l["next"]
|
||||
list_element = container.cast(gdb.lookup_type("GList").pointer())
|
||||
while long(list_element) != 0:
|
||||
self.do_iter(arg, list_element["data"], command)
|
||||
list_element = list_element["next"]
|
||||
|
||||
def pick_iterator(self, container):
|
||||
t = container.type.unqualified()
|
||||
|
@ -4,10 +4,13 @@
|
||||
#
|
||||
# ./update-gtranslit.py /path/to/glibc/localedata/locales > gtranslit-data.h
|
||||
|
||||
import sys, os
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
localedir = sys.argv[1]
|
||||
|
||||
|
||||
# returns true if the name looks like a POSIX locale name
|
||||
def looks_like_locale(name):
|
||||
name, _, variant = name.partition("@")
|
||||
@ -34,7 +37,7 @@ def unescape(string):
|
||||
chunks.append(string[i:])
|
||||
break
|
||||
|
||||
assert string[start_escape : start_escape + 2] == "<U"
|
||||
assert string[start_escape : (start_escape + 2)] == "<U"
|
||||
start_escape += 2
|
||||
|
||||
end_escape = string.find(">", start_escape)
|
||||
@ -65,7 +68,8 @@ class Mapping:
|
||||
|
||||
# Scans a string like
|
||||
#
|
||||
# <U00C4> "<U0041><U0308>";"<U0041><U0045>" % LATIN CAPITAL LETTER A WITH DIAERESIS.
|
||||
# <U00C4> "<U0041><U0308>";"<U0041><U0045>" % \
|
||||
# LATIN CAPITAL LETTER A WITH DIAERESIS.
|
||||
#
|
||||
# and adds the first all-ascii choice (or IGNORE) to the mapping
|
||||
# dictionary, with the origin string as the key. In the case of
|
||||
@ -227,7 +231,7 @@ chains = {}
|
||||
|
||||
|
||||
def get_chain(name):
|
||||
if not name in chains:
|
||||
if name not in chains:
|
||||
chains[name] = Chain(name)
|
||||
|
||||
return chains[name]
|
||||
@ -362,8 +366,6 @@ class Serialiser:
|
||||
|
||||
mappings_table.append((src_range, ascii_range))
|
||||
|
||||
mapping_end = len(mappings_table)
|
||||
|
||||
for chain in self.chains:
|
||||
chain_starts.append(len(chains_table))
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
import os.path
|
||||
import gdb
|
||||
import glib_gdb
|
||||
import sys
|
||||
@ -19,6 +18,7 @@ try:
|
||||
except ImportError:
|
||||
HAVE_GDB_FRAMEDECORATOR = False
|
||||
|
||||
|
||||
# This is not quite right, as local vars may override symname
|
||||
def read_global_var(symname):
|
||||
return gdb.selected_frame().read_var(symname)
|
||||
@ -44,7 +44,7 @@ def g_type_to_typenode(gtype):
|
||||
|
||||
def g_type_to_name(gtype):
|
||||
typenode = g_type_to_typenode(gtype)
|
||||
if typenode != None:
|
||||
if typenode is not None:
|
||||
return glib_gdb.g_quark_to_string(typenode["qname"])
|
||||
return None
|
||||
|
||||
@ -116,7 +116,7 @@ class GTypeHandlePrettyPrinter:
|
||||
|
||||
def to_string(self):
|
||||
typenode = g_type_to_typenode(self.val)
|
||||
if typenode != None:
|
||||
if typenode is not None:
|
||||
name = glib_gdb.g_quark_to_string(typenode["qname"])
|
||||
s = ("0x%x [%s%s") % (long(self.val), self.hint, name)
|
||||
for i in range(1, int(typenode["n_supers"])):
|
||||
@ -178,7 +178,7 @@ class SignalFrame(FrameDecorator):
|
||||
v = frame_var(frame, name)
|
||||
if v is None or v.is_optimized_out:
|
||||
return None
|
||||
if array != None:
|
||||
if array is not None:
|
||||
array.append(v)
|
||||
return v
|
||||
except ValueError:
|
||||
@ -191,8 +191,8 @@ class SignalFrame(FrameDecorator):
|
||||
return None
|
||||
v = v.cast(gdb.lookup_type("GObject").pointer())
|
||||
# Ensure this is a somewhat correct object pointer
|
||||
if v != None and g_type_name_from_instance(v):
|
||||
if array != None:
|
||||
if v is not None and g_type_name_from_instance(v):
|
||||
if array is not None:
|
||||
array.append(v)
|
||||
return v
|
||||
return None
|
||||
@ -200,7 +200,7 @@ class SignalFrame(FrameDecorator):
|
||||
return None
|
||||
|
||||
def append(self, array, obj):
|
||||
if obj != None:
|
||||
if obj is not None:
|
||||
array.append(obj)
|
||||
|
||||
def or_join_array(self, array):
|
||||
|
@ -32,6 +32,10 @@ import unittest
|
||||
import taptestrunner
|
||||
|
||||
|
||||
# Disable line length warnings as wrapping the C code templates would be hard
|
||||
# flake8: noqa: E501
|
||||
|
||||
|
||||
Result = collections.namedtuple("Result", ("info", "out", "err", "subs"))
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ import sys
|
||||
import base64
|
||||
from io import StringIO
|
||||
|
||||
|
||||
# Log modes
|
||||
class LogMode(object):
|
||||
LogToError, LogToDiagnostics, LogToYAML, LogToAttachment = range(4)
|
||||
|
@ -27,6 +27,10 @@ import sys
|
||||
import argparse
|
||||
|
||||
|
||||
# Disable line length warnings as wrapping the test templates would be hard
|
||||
# flake8: noqa: E501
|
||||
|
||||
|
||||
def main(argv):
|
||||
parser = argparse.ArgumentParser(
|
||||
description="Generate test cases for case mapping from Unicode data"
|
||||
@ -183,9 +187,9 @@ tr_TR.UTF-8\tI\u0307\ti\tI\u0307\tI\u0307\t# I => LATIN SMALL LETTER DOTLESS I
|
||||
\t\u03b1\u0345\u0314\t\u03b1\u0345\u0314\t\u0391\u0345\u0314\t\u0391\u0314\u0399\t
|
||||
\t\u03b1\u0314\u0345\t\u03b1\u0314\u0345\t\u0391\u0314\u0345\t\u0391\u0314\u0399\t
|
||||
# Handling of final and nonfinal sigma
|
||||
\tΜΆΙΟΣ μάιος Μάιος ΜΆΙΟΣ
|
||||
\tΜΆΙΟΣ μάιος Μάιος ΜΆΙΟΣ
|
||||
\tΣΙΓΜΑ σιγμα Σιγμα ΣΙΓΜΑ
|
||||
\tΜΆΙΟΣ μάιος Μάιος ΜΆΙΟΣ \t
|
||||
\tΜΆΙΟΣ μάιος Μάιος ΜΆΙΟΣ\t
|
||||
\tΣΙΓΜΑ σιγμα Σιγμα ΣΙΓΜΑ\t
|
||||
# Lithuanian rule of i followed by letter with dot. Not at all sure
|
||||
# about the titlecase part here
|
||||
lt_LT\ti\u0117\ti\u0117\tIe\tIE\t
|
||||
|
Loading…
Reference in New Issue
Block a user