This file is indexed.

/usr/lib/python3/dist-packages/glue/bin.py is in glue-sprite 0.13-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/usr/bin/env python
import os
import sys
import argparse

from PIL import Image as PImage

from glue.formats import formats
from glue.helpers import redirect_stdout
from glue import exceptions
from glue import managers
from glue import __version__


def main(argv=None):

    argv = (argv or sys.argv)[1:]

    parser = argparse.ArgumentParser(usage=("%(prog)s [source | --source | -s] [output | --output | -o]"))

    parser.add_argument("--source", "-s",
                        dest="source",
                        type=str,
                        default=os.environ.get('GLUE_SOURCE', None),
                        help="Source path")

    parser.add_argument("--output", "-o",
                        dest="output",
                        type=str,
                        default=os.environ.get('GLUE_OUTPUT', None),
                        help="Output path")

    parser.add_argument("-q", "--quiet",
                        dest="quiet",
                        action='store_true',
                        default=os.environ.get('GLUE_QUIET', False),
                        help="Suppress all normal output")

    parser.add_argument("-r", "--recursive",
                        dest="recursive",
                        action='store_true',
                        default=os.environ.get('GLUE_RECURSIVE', False),
                        help=("Read directories recursively and add all "
                              "the images to the same sprite."))

    parser.add_argument("--follow-links",
                        dest="follow_links",
                        action='store_true',
                        default=os.environ.get('GLUE_FOLLOW_LINKS', False),
                        help="Follow symbolic links.")

    parser.add_argument("-f", "--force",
                        dest="force",
                        action='store_true',
                        default=os.environ.get('GLUE_FORCE', False),
                        help=("Force glue to create every sprite image and "
                              "metadata file even if they already exists in "
                              "the output directory."))

    parser.add_argument("-w", "--watch",
                        dest="watch",
                        action='store_true',
                        default=os.environ.get('GLUE_WATCH', False),
                        help=("Watch the source folder for changes and rebuild "
                              "when new files appear, disappear or change."))

    parser.add_argument("--project",
                        dest="project",
                        action="store_true",
                        default=os.environ.get('GLUE_PROJECT', False),
                        help="Generate sprites for multiple folders")

    parser.add_argument("-v", "--version",
                        action="version",
                        version='%(prog)s ' + __version__,
                        help="Show program's version number and exit")

    group = parser.add_argument_group("Algorithm options")

    group.add_argument("-a", "--algorithm",
                       dest="algorithm",
                       metavar='NAME',
                       type=str,
                       default=os.environ.get('GLUE_ALGORITHM', 'square'),
                       choices=['square', 'vertical', 'horizontal',
                                'vertical-right', 'horizontal-bottom',
                                'diagonal'],
                       help=("Allocation algorithm: square, vertical, "
                             "horizontal, vertical-right, horizontal-bottom, "
                             "diagonal. (default: square)"))

    group.add_argument("--ordering",
                       dest="algorithm_ordering",
                       metavar='NAME',
                       type=str,
                       default=os.environ.get('GLUE_ORDERING', 'maxside'),
                       choices=['maxside', 'width', 'height', 'area', 'filename',
                                '-maxside', '-width', '-height', '-area', '-filename'],
                       help=("Ordering criteria: maxside, width, height, area or "
                             "filename (default: maxside)"))

    # Populate the parser with options required by other formats
    for format in formats.values():
        format.populate_argument_parser(parser)

    #
    # Handle deprecated arguments
    #

    group = parser.add_argument_group("Deprecated options")
    deprecated_arguments = {}

    def add_deprecated_argument(*args, **kwargs):
        group.add_argument(*args, **kwargs)
        deprecated_arguments[kwargs['dest']] = args[0]

    add_deprecated_argument("--global-template", dest="global_template")
    add_deprecated_argument("--each-template", dest="each_template")
    add_deprecated_argument("--ratio-template", dest="ratio_template")
    add_deprecated_argument("--ignore-filename-paddings", action='store_true',
                            dest="ignore_filename_paddings")
    add_deprecated_argument("--optipng", dest="optipng", action='store_true')
    add_deprecated_argument("--optipngpath", dest="optipngpath")
    add_deprecated_argument("--debug", action='store_true', dest="debug")
    add_deprecated_argument("--imagemagick", dest="imagemagick",
                            action='store_true')
    add_deprecated_argument("--imagemagickpath", dest="imagemagickpath")

    # Parse input
    options, args = parser.parse_known_args(argv)


    # Get the list of enabled formats
    options.enabled_formats = [f for f in formats if getattr(options, '{0}_dir'.format(f), False)]

    # If there is only one enabled format (img) or if there are two (img, html)
    # this means glue is been executed without any specific main format.
    # In order to keep the legacy API we need to enable css.
    # As consequence there is no way to make glue only generate the sprite
    # image and the html file without generating the css file too.
    if set(options.enabled_formats) in (set(['img']), set(['img', 'html'])) and options.generate_css:
        options.enabled_formats.append('css')
        setattr(options, "css_dir", True)

    if not options.generate_image:
        options.enabled_formats.remove('img')

    # Fail if any of the deprecated arguments is used
    for argument in deprecated_arguments.keys():
        if getattr(options, argument, None):
            parser.error(("{0} argument is deprectated "
                          "since v0.3").format(deprecated_arguments[argument]))

    extra = 0
    # Get the source from the source option or the first positional argument
    if not options.source and args:
        options.source = args[0]
        extra += 1

    # Get the output from the output option or the second positional argument
    if not options.output and args[extra:]:
        options.output = args[extra]

    # Check if source is available
    if options.source is None:
        parser.error(("You must provide the folder containing the sprites "
                      "using the first positional argument or --source."))

    # Make absolute both source and output if present
    if not os.path.isdir(options.source):
        parser.error("Directory not found: '{0}'".format(options.source))

    options.source = os.path.abspath(options.source)
    if options.output:
        options.output = os.path.abspath(options.output)

    # Check that both the source and the output are present. Output "enough"
    # information can be tricky as you can choose different outputs for each
    # of the available formats. If it is present make it absolute.
    if not options.source:
        parser.error(("Source required. Please specify a source using "
                      "--source or the first positional argument."))

    if options.output:
        for format in options.enabled_formats:
            format_option = '{0}_dir'.format(format)
            path = getattr(options, format_option)

            if isinstance(path, bool) and path:
                setattr(options, format_option, options.output)
    else:
        if options.generate_image and not options.img_dir:
            parser.error(("Output required. Please specify an output for "
                          "the sprite image using --output, the second "
                          "positional argument or --img=<DIR>"))

        for format in options.enabled_formats:
            format_option = '{0}_dir'.format(format)
            path = getattr(options, format_option)

            if isinstance(path, bool) or not path:
                parser.error(("{0} output required. Please specify an output "
                              "for {0} using --output, the second "
                              "positional argument or --{0}=<DIR>".format(format)))
            else:
                setattr(options, format_option, os.path.abspath(path))

    # If the img format is not enabled, we still need to know where the sprites
    # were generated. As img is not an enabled format img_dir would be empty
    # if --img was not userd. If this is the case we need to use whatever is
    # the output value.
    if not options.generate_image and isinstance(options.img_dir, bool):
        options.img_dir = options.output

    # Apply formats constraints
    for format in options.enabled_formats:
        formats[format].apply_parser_contraints(parser, options)

    if options.project:
        manager_cls = managers.ProjectManager
    else:
        manager_cls = managers.SimpleManager

    # Generate manager or defer the creation to a WatchManager
    if options.watch:
        manager = managers.WatchManager(manager_cls, vars(options))
    else:
        manager = manager_cls(**vars(options))

    try:
        if options.quiet:
            with redirect_stdout():
                manager.process()
        else:
            manager.process()
    except exceptions.ValidationError as e:
        sys.stderr.write(e.args[0])
        return e.error_code
    except exceptions.SourceImagesNotFoundError as e:
        sys.stderr.write("Error: No images found in %s.\n" % e.args[0])
        return e.error_code
    except exceptions.NoSpritesFoldersFoundError as e:
        sys.stderr.write("Error: No sprites folders found in %s.\n" % e.args[0])
        return e.error_code
    except exceptions.PILUnavailableError as e:
        sys.stderr.write(("Error: PIL {0} decoder is unavailable"
                          "Please read the documentation and "
                          "install it before spriting this kind of "
                          "images.\n").format(e.args[0]))
        return e.error_code
    except Exception:
        import platform
        import traceback
        sys.stderr.write("\n")
        sys.stderr.write("=" * 80)
        sys.stderr.write("\nYou've found a bug! Please, raise an issue attaching the following traceback\n")
        sys.stderr.write("https://github.com/jorgebastida/glue/issues/new\n")
        sys.stderr.write("-" * 80)
        sys.stderr.write("\n")
        sys.stderr.write("Version: {0}\n".format(__version__))
        sys.stderr.write("Python: {0}\n".format(sys.version))
        sys.stderr.write("PIL version: {0}\n".format(PImage.VERSION))
        sys.stderr.write("Platform: {0}\n".format(platform.platform()))
        sys.stderr.write("Config: {0}\n".format(vars(options)))
        sys.stderr.write("Args: {0}\n\n".format(sys.argv))
        sys.stderr.write(traceback.format_exc())
        sys.stderr.write("=" * 80)
        sys.stderr.write("\n")
        return 1

    return 0

if __name__ == "__main__":
    sys.exit(main())