Create a scene.rm message
517156
def scene_remove(sequence_number, scene_id):
        """"""
        return MessageWriter().string("scene.rm").uint64(sequence_number).uint32(scene_id).get()
413215
def build_image(self, msg):
        
        result = self.find_message(msg)

        if result is None:
            return

        self.index += 1
        images_path = 'images'

        if self.directory:
            images_path = os.path.join(self.directory, images_path)

        if not os.path.isdir(images_path):
            os.makedirs(images_path)

        with open('{0}/output_{1}.png'.format(images_path, self.index), 'wb') as fh:
            self.write_image_to_disk(msg, result, fh)

        self.out.append(
            '\n![png]({0}/output_{1}.png)\n'.format(images_path, self.index))
959427
def render_and_create_dir(dirname, context, output_dir, environment,
                          overwrite_if_exists=False):
    """"""
    name_tmpl = environment.from_string(dirname)
    rendered_dirname = name_tmpl.render(**context)

    dir_to_create = os.path.normpath(
        os.path.join(output_dir, rendered_dirname)
    )

    logger.debug('Rendered dir {} must exist in output_dir {}'.format(
        dir_to_create,
        output_dir
    ))

    output_dir_exists = os.path.exists(dir_to_create)

    if output_dir_exists:
        if overwrite_if_exists:
            logger.debug(
                'Output directory {} already exists,'
                'overwriting it'.format(dir_to_create)
            )
        else:
            msg = 'Error: "{}" directory already exists'.format(dir_to_create)
            raise OutputDirExistsException(msg)
    else:
        make_sure_path_exists(dir_to_create)

    return dir_to_create, not output_dir_exists
346293
def message_about_scripts_not_on_PATH(scripts):
    # type: (Sequence[str]) -> Optional[str]
    
    if not scripts:
        return None

    # Group scripts by the path they were installed in
    grouped_by_dir = collections.defaultdict(set)  # type: Dict[str, set]
    for destfile in scripts:
        parent_dir = os.path.dirname(destfile)
        script_name = os.path.basename(destfile)
        grouped_by_dir[parent_dir].add(script_name)

    # We don't want to warn for directories that are on PATH.
    not_warn_dirs = [
        os.path.normcase(i).rstrip(os.sep) for i in
        os.environ.get("PATH", "").split(os.pathsep)
    ]
    # If an executable sits with sys.executable, we don't warn for it.
    #     This covers the case of venv invocations without activating the venv.
    executable_loc = os.environ.get("PIP_PYTHON_PATH", sys.executable)
    not_warn_dirs.append(os.path.normcase(os.path.dirname(executable_loc)))
    warn_for = {
        parent_dir: scripts for parent_dir, scripts in grouped_by_dir.items()
        if os.path.normcase(parent_dir) not in not_warn_dirs
    }
    if not warn_for:
        return None

    # Format a message
    msg_lines = []
    for parent_dir, scripts in warn_for.items():
        scripts = sorted(scripts)
        if len(scripts) == 1:
            start_text = "script {} is".format(scripts[0])
        else:
            start_text = "scripts {} are".format(
                ", ".join(scripts[:-1]) + " and " + scripts[-1]
            )

        msg_lines.append(
            "The {} installed in '{}' which is not on PATH."
            .format(start_text, parent_dir)
        )

    last_line_fmt = (
        "Consider adding {} to PATH or, if you prefer "
        "to suppress this warning, use --no-warn-script-location."
    )
    if len(msg_lines) == 1:
        msg_lines.append(last_line_fmt.format("this directory"))
    else:
        msg_lines.append(last_line_fmt.format("these directories"))

    # Returns the formatted multiline message
    return "\n".join(msg_lines)
1324354
def generate_dir_rst(dir, fhindex, example_dir, root_dir, plot_gallery):
    
    if not dir == '.':
        target_dir = os.path.join(root_dir, dir)
        src_dir = os.path.join(example_dir, dir)
    else:
        target_dir = root_dir
        src_dir = example_dir
    if not os.path.exists(os.path.join(src_dir, 'README.txt')):
        print('Example directory %s does not have a README.txt file' % src_dir)
        print('Skipping this directory')
        print(80 * '_')
        return
    fhindex.write("""


%s


""" % file(os.path.join(src_dir, 'README.txt')).read())
    if not os.path.exists(target_dir):
        os.makedirs(target_dir)

    def sort_key(a):
        # put last elements without a plot
        if not a.startswith('plot') and a.endswith('.py'):
            return 'zz' + a
        return a

    fhindex.write("""

.. toctree::

""")
    for fname in sorted(os.listdir(src_dir), key=sort_key):
        if fname.endswith('py'):
            generate_file_rst(fname, target_dir, src_dir, plot_gallery)
            #thumb = os.path.join(dir, 'images', 'thumb', fname[:-3] + '.png')
            link_name = os.path.join(dir, fname).replace(os.path.sep, '_')
            #fhindex.write('.. figure:: %s\n' % thumb)
            #if link_name.startswith('._'):
            #    link_name = link_name[2:]
            #if dir != '.':
            #    fhindex.write('   :target: ./%s/%s.html\n\n' % (dir,
            #                                                   fname[:-3]))
            #else:
            #    fhindex.write('   :target: ./%s.html\n\n' % link_name[:-3])
            fhindex.write("""
   %s/%s
""" % (dir, fname[:-3]))
    fhindex.write("""

.. raw:: html

    <div style="clear: both"></div>
    """)
713608
async def create_scene_member(self, shade_position, scene_id, shade_id):
        """"""

        data = {
            ATTR_SCENE_MEMBER: {
                ATTR_POSITION_DATA: shade_position,
                ATTR_SCENE_ID: scene_id,
                ATTR_SHADE_ID: shade_id,
            }
        }
        return await self.request.post(self._base_path, data=data)
648352
def rm(self, filename):
        """"""
        command = """
            try:
                import os
            except ImportError:
                import uos as os
            os.remove('{0}')
        """.format(
            filename
        )
        self._pyboard.enter_raw_repl()
        try:
            out = self._pyboard.exec_(textwrap.dedent(command))
        except PyboardError as ex:
            message = ex.args[2].decode("utf-8")
            # Check if this is an OSError #2, i.e. file/directory doesn't exist
            # and rethrow it as something more descriptive.
            if message.find("OSError: [Errno 2] ENOENT") != -1:
                raise RuntimeError("No such file/directory: {0}".format(filename))
            # Check for OSError #13, the directory isn't empty.
            if message.find("OSError: [Errno 13] EACCES") != -1:
                raise RuntimeError("Directory is not empty: {0}".format(filename))
            else:
                raise ex
        self._pyboard.exit_raw_repl()
1057706
def SETUP(self):
        """"""
        message = "SETUP " + self.session.control_url + " RTSP/1.0\r\n"
        message += self.sequence
        message += self.authentication
        message += self.user_agent
        message += self.transport
        message += '\r\n'
        return message
477757
async def create_scene(self, scene_name, room_id) -> Scene:
        
        _raw = await self._scenes_entry_point.create_scene(room_id, scene_name)
        result = Scene(_raw, self.request)
        self.scenes.append(result)
        return result
725955
private void generateScenes(final Metadata m, final Element e) {
        final Element scenesElement = new Element("scenes", NS);
        for (final Scene scene : m.getScenes()) {
            final Element sceneElement = new Element("scene", NS);
            addNotNullElement(sceneElement, "sceneTitle", scene.getTitle());
            addNotNullElement(sceneElement, "sceneDescription", scene.getDescription());
            addNotNullElement(sceneElement, "sceneStartTime", scene.getStartTime());
            addNotNullElement(sceneElement, "sceneEndTime", scene.getEndTime());
            if (!sceneElement.getChildren().isEmpty()) {
                scenesElement.addContent(sceneElement);
            }
        }
        if (!scenesElement.getChildren().isEmpty()) {
            e.addContent(scenesElement);
        }
    }
911801
def message(m, fd=sys.stdout):
    """"""

    if sys.platform == 'win32':
        decoding = sys.stdout.encoding if sys.version_info[0] > 2 else 'cp1252'
        click.echo(MaltegoMessage(message=m).render(fragment=True, encoding='utf-8').decode(decoding), file=fd)
    else:
        click.echo(MaltegoMessage(message=m).render(encoding='utf-8', fragment=True), file=fd)
    exit(0)
784594
def message(self, message, source, point, ln):
        """"""
        if message is None:
            message = "parsing failed"
        if ln is not None:
            message += " (line " + str(ln) + ")"
        if source:
            if point is None:
                message += "\n" + " " * taberrfmt + clean(source)
            else:
                part = clean(source.splitlines()[lineno(point, source) - 1], False).lstrip()
                point -= len(source) - len(part)  # adjust all points based on lstrip
                part = part.rstrip()  # adjust only points that are too large based on rstrip
                message += "\n" + " " * taberrfmt + part
                if point > 0:
                    if point >= len(part):
                        point = len(part) - 1
                    message += "\n" + " " * (taberrfmt + point) + "^"
        return message
793638
def _add_message_file(arg_parser, help_text):
    
    arg_parser.add_argument('--msg-file',
                            type=argparse.FileType('r'),
                            help=help_text)
1084829
def message
      @message ||= (
        path = Dir[file].first if file
        if path
          project.announcement(File.new(file))
        else
          parts.map{ |part| /^file:\/\// =~ part.to_s ? $' : part }
          project.announcement(*parts)
        end
      )
    end
3604
def generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs):
    """"""

    head_ref = os.path.relpath(target_dir, gallery_conf['src_dir'])
    fhindex = """\n\n.. _sphx_glr_{0}:\n\n""".format(
        head_ref.replace(os.path.sep, '_'))

    with codecs.open(os.path.join(src_dir, 'README.txt'), 'r',
                     encoding='utf-8') as fid:
        fhindex += fid.read()
    # Add empty lines to avoid bug in issue #165
    fhindex += "\n\n"

    if not os.path.exists(target_dir):
        os.makedirs(target_dir)
    # get filenames
    listdir = [fname for fname in os.listdir(src_dir)
               if fname.endswith('.py')]
    # limit which to look at based on regex (similar to filename_pattern)
    listdir = [fname for fname in listdir
               if re.search(gallery_conf['ignore_pattern'],
                            os.path.normpath(os.path.join(src_dir, fname)))
               is None]
    # sort them
    sorted_listdir = sorted(
        listdir, key=gallery_conf['within_subsection_order'](src_dir))
    entries_text = []
    computation_times = []
    build_target_dir = os.path.relpath(target_dir, gallery_conf['src_dir'])
    iterator = sphinx_compatibility.status_iterator(
        sorted_listdir,
        'generating gallery for %s... ' % build_target_dir,
        length=len(sorted_listdir))
    clean_modules(gallery_conf, src_dir)  # fix gh-316
    for fname in iterator:
        intro, time_elapsed = generate_file_rst(
            fname, target_dir, src_dir, gallery_conf)
        clean_modules(gallery_conf, fname)
        src_file = os.path.normpath(os.path.join(src_dir, fname))
        computation_times.append((time_elapsed, src_file))
        this_entry = _thumbnail_div(target_dir, gallery_conf['src_dir'],
                                    fname, intro) + """

.. toctree::
   :hidden:

   /%s\n""" % os.path.join(build_target_dir, fname[:-3]).replace(os.sep, '/')
        entries_text.append(this_entry)

        if gallery_conf['backreferences_dir']:
            write_backreferences(seen_backrefs, gallery_conf,
                                 target_dir, fname, intro)

    for entry_text in entries_text:
        fhindex += entry_text

    # clear at the end of the section
    fhindex += """.. raw:: html\n
    <div style='clear:both'></div>\n\n"""

    return fhindex, computation_times
1065219
def publish_scene_remove(self, scene_id):
        """"""
        self.sequence_number += 1
        self.publisher.send_multipart(msgs.MessageBuilder.scene_remove(self.sequence_number, scene_id))
        return self.sequence_number
989246
def build_message(self):
        '''
        '''
        if self._text is None:
            raise InvalidPayloadError('text is required')

        message = {
            'text': self._text,
            'markdown': self._markdown
        }

        if self._channel != Incoming.DEFAULT_CHANNEL:
            message['channel'] = self._channel

        if self._attachments:
            message['attachments'] = []
            for attachment in self._attachments:
                if 'title' not in attachment and 'text' not in attachment:
                    raise InvalidPayloadError('title or text is required')
                message['attachments'].append(attachment)

        return message