text:
<?xml version='1.0'?>
<!DOCTYPE sconsdoc [
    <!ENTITY % scons SYSTEM "../scons.mod">
    %scons;
]>

<chapter id="chap-engine"
         xmlns="http://www.scons.org/dbxsd/v1.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://www.scons.org/dbxsd/v1.0 http://www.scons.org/dbxsd/v1.0/scons.xsd">
<title>Build Engine API</title>

 <title>General Principles</title>

  <title>Keyword arguments</title>

  <para>

   All methods and functions in this API will support the use of keyword
   arguments in calls, for the sake of explicitness and readability.
   For brevity in the hands of experts, most methods and functions
   will also support positional arguments for their most-commonly-used
   arguments.  As an explicit example, the following two lines will each
   arrange for an executable program named <filename>foo</filename> (or
   <filename>foo.exe</filename> on a Win32 system) to be compiled from
   the <filename>foo.c</filename> source file:

  </para>

	<programlisting>
	env.Program(target = 'foo', source = 'foo.c')

	env.Program('foo', 'foo.c')
	</programlisting>

  <title>Internal object representation</title>

  <para>

   All methods and functions use internal (Python) objects that
   represent the external objects (files, for example) for which they
   perform dependency analysis.

  </para>

  <para>

   All methods and functions in this API that accept an external object
   as an argument will accept <emphasis>either</emphasis> a string
   description or an object reference.  For example, the two following
   two-line examples are equivalent:

  </para>

	<programlisting>
	env.Object(target = 'foo.o', source = 'foo.c')
	env.Program(target = 'foo', 'foo.o')    # builds foo from foo.o

	foo_obj = env.Object(target = 'foo.o', source = 'foo.c')
	env.Program(target = 'foo', foo_obj)    # builds foo from foo.o
	</programlisting>

 <title>&ConsEnvs;</title>

 <para>

  A &consenv; is the basic means by which a software system interacts
  with the &SCons; Python API to control a build process.

 </para>

 <para>

  A &consenv; is an object with associated methods for generating target
  files of various types (&Builder; objects), other associated object
  methods for automatically determining dependencies from the contents
  of various types of source files (&Scanner; objects), and a dictionary
  of values used by these methods.

 </para>

 <para>

  Passing no arguments to the &Environment; instantiation creates a
  &consenv; with default values for the current platform:

 </para>

	<programlisting>
	env = Environment()
	</programlisting>

  <title>&Consvars;</title>

  <para>

   A &consenv; has an associated dictionary of &consvars; that control how
   the build is performed.  By default, the &Environment; method creates
   a &consenv; with values that make most software build "out of the box"
   on the host system.  These default values will be generated at the
   time &SCons; is installed using functionality similar to that provided
   by GNU &Autoconf;.
   <footnote>
    <para>
     It would be nice if we could avoid re-inventing the wheel here by
     using some other Python-based tool &Autoconf; replacement--like what
     was supposed to come out of the Software Carpentry configuration
     tool contest.  It will probably be most efficient to roll our own
     logic initially and convert if something better does come along.
    </para>
   </footnote>
   At a minimum, there will be pre-configured sets of default values
   that will provide reasonable defaults for UNIX and Windows NT.

  </para>

  <para>

   The default &consenv; values may be overridden when a new &consenv; is
   created by specifying keyword arguments:

  </para>

	<programlisting>
	env = Environment(CC =          'gcc',
	                  CCFLAGS =    '-g',
	                  CPPPATH =    ['.', 'src', '/usr/include'],
	                  LIBPATH =    ['/usr/lib', '.'])
	</programlisting>

  <title>Fetching &consvars;</title>

  <para>

   A copy of the dictionary of &consvars; can be returned using
   the &Dictionary; method:

  </para>

	<programlisting>
	env = Environment()
	dict = env.Dictionary()
	</programlisting>

  <para>

   If any arguments are supplied, then just the corresponding value(s)
   are returned:

  </para>

	<programlisting>
	ccflags = env.Dictionary('CCFLAGS')
	cc, ld = env.Dictionary('CC', 'LD')
	</programlisting>

  <title>Copying a &consenv;</title>

  <para>

   A method exists to return a copy of an existing environment, with
   any overridden values specified as keyword arguments to the method:

  </para>

	<programlisting>
	env = Environment()
	debug = env.Copy(CCFLAGS = '-g')
	</programlisting>

  <title>Multiple &consenvs;</title>

  <para>

   Different external objects often require different build
   characteristics.  Multiple &consenvs; may be defined, each with
   different values:

  </para>

	<programlisting>
	env = Environment(CCFLAGS = '')
	debug = Environment(CCFLAGS = '-g')
	env.Make(target = 'hello', source = 'hello.c')
	debug.Make(target = 'hello-debug', source = 'hello.c')
	</programlisting>

  <para>

   Dictionaries of values from multiple &consenvs; may be passed to the
   &Environment; instantiation or the &Copy; method, in which case the
   last-specified dictionary value wins:

  </para>

	<programlisting>
	env1 = Environment(CCFLAGS = '-O', LDFLAGS = '-d')
	env2 = Environment(CCFLAGS = '-g')
	new = Environment(env1.Dictionary(), env2.Dictionary())
	</programlisting>

  <para>

   The <varname>new</varname> environment in the above example retains
   <literal>LDFLAGS = '-d'</literal> from the <varname>env1</varname>
   environment, and <literal>CCFLAGS = '-g'</literal> from the
   <varname>env2</varname> environment.

  </para>

  <title>Variable substitution</title>

  <para>

   Within a construction command, any variable from the &consenv; may
   be interpolated by prefixing the name of the construction with
   <symbol>$</symbol>:

  </para>

	<programlisting>
	MyBuilder = Builder(command = "$XX $XXFLAGS -c $_INPUTS -o $target")

	env.Command(targets = 'bar.out', sources = 'bar.in',
	            command = "sed '1d' < $source > $target")
	</programlisting>

  <para>

   Variable substitution is recursive:  the command line is expanded
   until no more substitutions can be made.

  </para>

  <para>

   Variable names following the <symbol>$</symbol> may be enclosed in
   braces.  This can be used to concatenate an interpolated value with an
   alphanumeric character:

  </para>

	<programlisting>
	VerboseBuilder = Builder(command = "$XX -${XXFLAGS}v > $target")
	</programlisting>

  <para>

   The variable within braces may contain a pair of parentheses
   after a Python function name to be evaluated (for example,
   <literal>${map()}</literal>).  &SCons; will interpolate the return
   value from the function (presumably a string):

  </para>

	<programlisting>
	env = Environment(FUNC = myfunc)
	env.Command(target = 'foo.out', source = 'foo.in',
	            command = "${FUNC($<)}")
	</programlisting>

  <para>

   If a referenced variable is not defined in the &consenv;,
   the null string is interpolated.

  </para>

  <para>

   The following special variables can also be used:

  </para>

  <variablelist>

   <varlistentry>
    <term><literal>$targets</literal></term>
    <listitem>
     <para>

      All target file names.  If multiple targets are specified in an
      array, <literal>$targets</literal> expands to the entire list of
      targets, separated by a single space.

    </para>

    <para>

      Individual targets from a list may be extracted by enclosing
      the <literal>targets</literal> keyword in braces and using the
      appropriate Python array index or slice:

    </para>

	<programlisting>
	${targets[0]}     # expands to the first target

	${targets[1:]}    # expands to all but the first target

	${targets[1:-1]}  # expands to all but the first and last targets
	</programlisting>

    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>$target</literal></term>
    <listitem>
     <para>

      A synonym for <literal>${targets[0]}</literal>, the first target
      specified.

     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>$sources</literal></term>
    <listitem>
     <para>

      All input file names.  Any input file names that
      are used anywhere else on the current command
      line (via <literal>${sources[0]}</literal>,
      <literal>${sources{[1]}</literal>, etc.) are removed from the
      expanded list.

     </para>
    </listitem>
   </varlistentry>

  </variablelist>

  <para>

   Any of the above special variables may be enclosed in braces and
   followed immediately by one of the following attributes to select just
   a portion of the expanded path name:

  </para>

  <variablelist>

   <varlistentry>
    <term><literal>.base</literal></term>
    <listitem>
     <para>

      Basename: the directory plus the file name, minus any file suffix.

     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>.dir</literal></term>
    <listitem>
     <para>

      The directory in which the file lives.  This is a relative path,
      where appropriate.

     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>.file</literal></term>
    <listitem>
     <para>

      The file name, minus any directory portion.

     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>.suffix</literal></term>
    <listitem>
     <para>

      The file name suffix (that is, the right-most dot in the file name,
      and all characters to the right of that).

     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>.filebase</literal></term>
    <listitem>
     <para>

      The file name (no directory portion), minus any file suffix.

     </para>
    </listitem>
   </varlistentry>

   <varlistentry>
    <term><literal>.abspath</literal></term>
    <listitem>
     <para>

      The absolute path to the file.

     </para>
    </listitem>
   </varlistentry>

  </variablelist>

 <title>&Builder; Objects</title>

 <para>

  By default, &SCons; supplies (and uses) a number of pre-defined
  &Builder; objects:

 </para>

 <informaltable>
  <tgroup cols="2">

   <row>
    <entry>&Object;</entry>
    <entry>compile or assemble an object file</entry>
   </row>

   <row>
    <entry>&Library;</entry>
    <entry>archive files into a library</entry>
   </row>

   <row>
    <entry>&SharedLibrary;</entry>
    <entry>archive files into a shared library</entry>
   </row>

   <row>
    <entry>&Program;</entry>
    <entry>link objects and/or libraries into an executable</entry>
   </row>

   <row>
    <entry>&MakeBuilder;</entry>
    <entry>build according to file suffixes; see below</entry>
   </row>

  </tgroup>
 </informaltable>

 <para>

  A &consenv; can be explicitly initialized with associated &Builder;
  objects that will be bound to the &consenv; object:

 </para>

	<programlisting>
	env = Environment(BUILDERS = ['Object', 'Program'])
	</programlisting>

 <para>

  &Builder; objects bound to a &consenv; can be called directly as
  methods.  When invoked, a &Builder; object returns a (list of) objects
  that it will build:

 </para>

	<programlisting>
	obj = env.Object(target ='hello.o', source = 'hello.c')
	lib = env.Library(target ='libfoo.a',
	                  source = ['aaa.c', 'bbb.c'])
	slib = env.SharedLibrary(target ='libbar.so',
	                         source = ['xxx.c', 'yyy.c'])
	prog = env.Program(target ='hello',
	                   source = ['hello.o', 'libfoo.a', 'libbar.so'])
	</programlisting>

  <title>Specifying multiple inputs</title>

  <para>

   Multiple input files that go into creating a target file may be passed
   in as a single string, with the individual file names separated by
   white space:

  </para>

	<programlisting>
	env.Library(target = 'foo.a', source = 'aaa.c bbb.c ccc.c')
	env.Object(target = 'yyy.o', source = 'yyy.c')
	env.Program(target = 'bar', source = 'xxx.c yyy.o foo.a')
	</programlisting>

  <para>

   Alternatively, multiple input files that go into creating a target
   file may be passed in as an array.  This allows input files to be
   specified using their object representation:

  </para>

	<programlisting>
	env.Library(target = 'foo.a', source = ['aaa.c', 'bbb.c', 'ccc.c'])
	yyy_obj = env.Object(target = 'yyy.o', source = 'yyy.c')
	env.Program(target = 'bar', source = ['xxx.c', yyy_obj, 'foo.a'])
	</programlisting>

   <para>

    Individual string elements within an array of input files are
    <emphasis>not</emphasis> further split into white-space separated
    file names.  This allows file names that contain white space to
    be specified by putting the value into an array:

	<programlisting>
	env.Program(target = 'foo', source = ['an input file.c'])
	</programlisting>

   </para>

  <title>Specifying multiple targets</title>

  <para>

   Conversely, the generated target may be a string listing multiple
   files separated by white space:

  </para>

	<programlisting>
	env.Object(target = 'grammar.o y.tab.h', source = 'grammar.y')
	</programlisting>

  <para>

   An array of multiple target files can be used to mix string and object
   representations, or to accomodate file names that contain white space:

  </para>

	<programlisting>
	env.Program(target = ['my program'], source = 'input.c')
	</programlisting>

  <title>File prefixes and suffixes</title>

  <para>

   For portability, if the target file name does not already have an
   appropriate file prefix or suffix, the &Builder; objects will
   append one appropriate for the file type on the current system:

  </para>

	<programlisting>
	# builds 'hello.o' on UNIX, 'hello.obj' on Windows NT:
	obj = env.Object(target ='hello', source = 'hello.c')

	# builds 'libfoo.a' on UNIX, 'foo.lib' on Windows NT:
	lib = env.Library(target ='foo', source = ['aaa.c', 'bbb.c'])

	# builds 'libbar.so' on UNIX, 'bar.dll' on Windows NT:
	slib = env.SharedLibrary(target ='bar', source = ['xxx.c', 'yyy.c'])

	# builds 'hello' on UNIX, 'hello.exe' on Windows NT:
	prog = env.Program(target ='hello',
	                   source = ['hello.o', 'libfoo.a', 'libbar.so'])
	</programlisting>

  <title>&Builder; object exceptions</title>

  <para>

   &Builder; objects raise the following exceptions on error:

  </para>

  <title>User-defined &Builder; objects</title>

  <para>

   Users can define additional &Builder; objects for specific external
   object types unknown to &SCons;.  A &Builder; object may build its
   target by executing an external command:

  </para>

	<programlisting>
	WebPage = Builder(command = 'htmlgen $HTMLGENFLAGS $sources > $target',
	                  suffix = '.html',
	                  src_suffix = '.in')
	</programlisting>

  <para>

   Alternatively, a &Builder; object may also build its target by
   executing a Python function:

   </para>

	<programlisting>
	def update(dest):
	        # [code to update the object]
	        return 1

	OtherBuilder1 = Builder(function = update,
	                        src_suffix = ['.in', '.input'])
	</programlisting>

   <para>

   An optional argument to pass to the function may be specified:

  </para>

	<programlisting>
	def update_arg(dest, arg):
	        # [code to update the object]
	        return 1

	OtherBuilder2 = Builder(function = update_arg,
	                        function_arg = 'xyzzy',
	                        src_suffix = ['.in', '.input'])
	</programlisting>

  <para>

   Both an external command and an internal function may be specified,
   in which case the function will be called to build the object first,
   followed by the command line.

  </para>

  <para>

   User-defined &Builder; objects can be used like the default &Builder;
   objects to initialize &consenvs;.

  </para>

	<programlisting>
	WebPage = Builder(command = 'htmlgen $HTMLGENFLAGS $sources > $target',
	                  suffix = '.html',
	                  src_suffix = '.in')
	env = Environment(BUILDERS = ['WebPage'])
	env.WebPage(target = 'foo.html', source = 'foo.in')
	# Builds 'bar.html' on UNIX, 'bar.htm' on Windows NT:
	env.WebPage(target = 'bar', source = 'bar.in')
	</programlisting>

  <para>

   The command-line specification can interpolate variables from the
   &consenv;; see "Variable substitution," above.

  </para>

  <para>

   A &Builder; object may optionally be initialized with a list of:

  </para>

   <itemizedlist>
     <listitem>
     <para>

       the prefix of the target file (e.g., 'lib' for libraries)

     </para>
     </listitem>

     <listitem>
     <para>

       the suffix of the target file (e.g., '.a' for libraries)

     </para>
     </listitem>

     <listitem>
     <para>

       the expected suffixes of the input files
       (e.g., '.o' for object files)

     </para>
     </listitem>
   </itemizedlist>

   <para>

    These arguments are used in automatic
    dependency analysis and to generate output file names that don't
    have suffixes supplied explicitly.

  </para>

  <title>Copying &Builder; Objects</title>

  <para>

   A &Copy; method exists to return a copy of an existing &Builder;
   object, with any overridden values specified as keyword arguments to
   the method:

  </para>

	<programlisting>
	build = Builder(function = my_build)
	build_out = build.Copy(suffix = '.out')
	</programlisting>

  <para>

   Typically, &Builder; objects will be supplied by a tool-master or
   administrator through a shared &consenv;.

  </para>

  <title>Special-purpose build rules</title>

  <para>

   A pre-defined &Command; builder exists to associate a target file with
   a specific command or list of commands for building the file:

  </para>

	<programlisting>
	env.Command(target = 'foo.out', source =
	            command = 'foo.in', "foo.process $sources > $target")

	commands = [    "bar.process -o .tmpfile $sources",
	                "mv .tmpfile $target" ]
	env.Command(target = 'bar.out', source = 'bar.in', command = commands)
	</programlisting>

  <para>
   This is useful when it's too cumbersome to create a &Builder;
   object just to build a single file in a special way.

  </para>

  <title>The &MakeBuilder; &Builder;</title>

  <para>

   A pre-defined &Builder; object named &MakeBuilder; exists to make
   simple builds as easy as possible for users, at the expense of
   sacrificing some build portability.

  </para>

  <para>

   The following minimal example builds the 'hello' program from the
   'hello.c' source file:

  </para>

	<programlisting>
	Environment().Make('hello', 'hello.c')
	</programlisting>

  <para>

   Users of the &MakeBuilder; &Builder; object are not required to
   understand intermediate steps involved in generating a file--for
   example, the distinction between compiling source code into an object
   file, and then linking object files into an executable.  The details
   of intermediate steps are handled by the invoked method.  Users that
   need to, however, can specify intermediate steps explicitly:

  </para>

	<programlisting>
	env = Environment()
	env.Make(target = 'hello.o', source = 'hello.c')
	env.Make(target = 'hello', source = 'hello.o')
	</programlisting>

  <para>

   The &MakeBuilder; method understands the file suffixes specified and
   "does the right thing" to generate the target object and program
   files, respectively.  It does this by examining the specified output
   suffixes for the &Builder; objects bound to the environment.

  </para>

  <para>

   Because file name suffixes in the target and source file names
   must be specified, the &MakeBuilder; method can't be used
   portably across operating systems.  In other words, for the
   example above, the &MakeBuilder; builder will not generate
   <filename>hello.exe</filename> on Windows NT.

  </para>

  <title>&Builder; maps</title>

  <para>

   The <function>env.Make</function> method "does the right thing" to
   build different file types because it uses a dictionary from the
   &consenv; that maps file suffixes to the appropriate &Builder; object.
   This &BUILDERMAP; can be initialized at instantiation:

  </para>

	<programlisting>
	env = Environment(BUILDERMAP = {
	                        '.o' : Object,
	                        '.a' : Library,
	                        '.html' : WebPage,
	                        '' : Program,
	                })
	</programlisting>

  <para>

   With the &BUILDERMAP; properly initialized, the
   <function>env.Make</function> method can be used to build additional
   file types:

  </para>

	<programlisting>
	env.Make(target = 'index.html', source = 'index.input')
	</programlisting>

  <para>

   &Builder; objects referenced in the &BUILDERMAP; do not need to be
   listed separately in the <literal>BUILDERS</literal> variable.  The &consenv; will
   bind the union of the &Builder; objects listed in both variables.

  </para>

 <title>Dependencies</title>

  <title>Automatic dependencies</title>

  <para>

   By default, &SCons; assumes that a target file has <literal>automatic
   dependencies</literal> on the:

  </para>

   <simplelist>

    <member>tool used to build the target file</member>

    <member>contents of the input files</member>

    <member>command line used to build the target file</member>

   </simplelist>

  <para>

   If any of these changes, the target file will be rebuilt.

  </para>

  <title>Implicit dependencies</title>

  <para>

   Additionally, &SCons; can scan the contents of files for
   <literal>implicit dependencies</literal> on other files.  For
   example, &SCons; will scan the contents of a <filename>.c</filename>
   file and determine that any object created from it is
   dependent on any <filename>.h</filename> files specified via
   <literal>#include</literal>.  &SCons;, therefore, "does the right
   thing" without needing to have these dependencies listed explicitly:

  </para>

	<programlisting>
	% cat Construct
	env = Environment()
	env.Program('hello', 'hello.c')
	% cat hello.c
	#include "hello_string.h"
	main()
	{
	        printf("%s\n", STRING);
	}
	% cat > hello_string.h
	#define STRING  "Hello, world!\n"
	% scons .
	gcc -c hello.c -o hello.o
	gcc -o hello hello.c
	% ./hello
	Hello, world!
	% cat > hello_string.h
	#define STRING  "Hello, world, hello!\n"
	% scons .
	gcc -c hello.c -o hello.o
	gcc -o hello hello.c
	% ./hello
	Hello, world, hello!
	%
	</programlisting>

  <title>Ignoring dependencies</title>

  <para>

   Undesirable <literal>automatic dependencies</literal> or
   <literal>implicit dependencies</literal> may be ignored:

  </para>

	<programlisting>
	env.Program(target = 'bar', source = 'bar.c')
	env.Ignore('bar', '/usr/bin/gcc', 'version.h')
	</programlisting>

  <para>

   In the above example, the <filename>bar</filename> program will not
   be rebuilt if the <filename>/usr/bin/gcc</filename> compiler or the
   <filename>version.h</filename> file change.

  </para>

  <title>Explicit dependencies</title>

  <para>

   Dependencies that are unknown to &SCons; may be specified explicitly
   in an &SCons; configuration file:

  </para>

	<programlisting>
	env.Dependency(target = 'output1', dependency = 'input_1 input_2')
	env.Dependency(target = 'output2', dependency = ['input_1', 'input_2'])
	env.Dependency(target = 'output3', dependency = ['white space input'])

	env.Dependency(target = 'output_a output_b', dependency = 'input_3')
	env.Dependency(target = ['output_c', 'output_d'], dependency = 'input_4')
	env.Dependency(target = ['white space output'], dependency = 'input_5')
	</programlisting>

  <para>

   Just like the <literal>target</literal> keyword argument, the
   <literal>dependency</literal> keyword argument may be specified as a
   string of white-space separated file names, or as an array.

  </para>

  <para>

   A dependency on an &SCons; configuration file itself may be specified
   explicitly to force a rebuild whenever the configuration file changes:

  </para>

	<programlisting>
	env.Dependency(target = 'archive.tar.gz', dependency = 'SConstruct')
	</programlisting>

 <title>&Scanner; Objects</title>

 <para>

  Analagous to the previously-described &Builder; objects, &SCons;
  supplies (and uses) &Scanner; objects to search the contents of
  a file for implicit dependency files:

 </para>

 <informaltable>
  <tgroup cols="2">

   <row>
    <entry>CScan</entry>
    <entry>scan .{c,C,cc,cxx,cpp} files for #include dependencies</entry>
   </row>

  </tgroup>
 </informaltable>

 <para>

  A &consenv; can be explicitly initialized with
  associated &Scanner; objects:

 </para>

	<programlisting>
	env = Environment(SCANNERS = ['CScan', 'M4Scan'])
	</programlisting>

 <para>

  &Scanner; objects bound to a &consenv; can be
  associated directly with specified files:

 </para>

	<programlisting>
	env.CScan('foo.c', 'bar.c')
	env.M4Scan('input.m4')
	</programlisting>

  <title>User-defined &Scanner; objects</title>

  <para>

   A user may define a &Scanner; object to scan a type of file for
   implicit dependencies:

  </para>

	<programlisting>
	def scanner1(file_contents):
	        # search for dependencies
	        return dependency_list

	FirstScan = Scanner(function = scanner1)
	</programlisting>

  <para>

   The scanner function must return a list of dependencies that its finds
   based on analyzing the file contents it is passed as an argument.

  </para>

  <para>

   The scanner function, when invoked, will be passed the calling
   environment.  The scanner function can use &consenvs; from the passed
   environment to affect how it performs its dependency scan--the
   canonical example being to use some sort of search-path construction
   variable to look for dependency files in other directories:

  </para>

	<programlisting>
	def scanner2(file_contents, env):
	        path = env.{'SCANNERPATH'}	# XXX
	        # search for dependencies using 'path'
	        return dependency_list

	SecondScan = Scanner(function = scanner2)
	</programlisting>

  <para>

   The user may specify an additional argument when the &Scanner; object
   is created.  When the scanner is invoked, the additional argument
   will be passed to the scanner funciton, which can be used in any way
   the scanner function sees fit:

  </para>

	<programlisting>
	def scanner3(file_contents, env, arg):
	        # skip 'arg' lines, then search for dependencies
	        return dependency_list

	Skip_3_Lines_Scan = Scanner(function = scanner2, argument = 3)
	Skip_6_Lines_Scan = Scanner(function = scanner2, argument = 6)
	</programlisting>

  <title>Copying &Scanner; Objects</title>

  <para>

   A method exists to return a copy of an existing &Scanner; object,
   with any overridden values specified as keyword arguments to the
   method:

  </para>

	<programlisting>
	scan = Scanner(function = my_scan)
	scan_path = scan.Copy(path = '%SCANNERPATH')
	</programlisting>

  <para>

   Typically, &Scanner; objects will be supplied by a tool-master or
   administrator through a shared &consenv;.

  </para>

  <title>&Scanner; maps</title>

  <para>

   Each &consenv; has a &SCANNERMAP;, a dictionary that associates
   different file suffixes with a scanner object that can be used to
   generate a list of dependencies from the contents of that file.  This
   &SCANNERMAP; can be initialized at instantiation:

  </para>

	<programlisting>
	env = Environment(SCANNERMAP = {
	                        '.c' : CScan,
	                        '.cc' : CScan,
	                        '.m4' : M4Scan,
	                })
	</programlisting>

  <para>

   &Scanner; objects referenced in the &SCANNERMAP; do not need to
   be listed separately in the <literal>SCANNERS</literal> variable.  The &consenv;
   will bind the union of the &Scanner; objects listed
   in both variables.

  </para>

 <title>Targets</title>

 <para>

  The methods in the build engine API described so far merely
  establish associations that describe file dependencies, how a
  file should be scanned, etc.  Since the real point is to actually
  <emphasis>build</emphasis> files, &SCons; also has methods that
  actually direct the build engine to build, or otherwise manipulate,
  target files.

 </para>

  <title>Building targets</title>
  <para>

   One or more targets may be built as follows:

  </para>

	<programlisting>
	env.Build(target = ['foo', 'bar'])
	</programlisting>

  <para>

   Note that specifying a directory (or other collective object) will
   cause all subsidiary/dependent objects to be built as well:

  </para>

	<programlisting>
	env.Build(target = '.')

	env.Build(target = 'builddir')
	</programlisting>

  <para>

   By default, &SCons; explicitly removes a target file before
   invoking the underlying function or command(s) to build it.

  </para>

  <title>Removing targets</title>

  <para>

   A "cleanup" operation of removing generated (target) files is
   performed as follows:

  </para>

	<programlisting>
	env.Clean(target = ['foo', 'bar'])
	</programlisting>

  <para>

   Like the &Build; method, the &Clean; method may be passed a
   directory or other collective object, in which case the subsidiary
   target objects under the directory will be removed:

  </para>

	<programlisting>
	env.Clean(target = '.')

	env.Clean(target = 'builddir')
	</programlisting>

  <para>

   (The directories themselves are not removed.)

  </para>

  <title>Suppressing cleanup removal of build-targets</title>

  <para>

    By default, &SCons; explicitly removes all build-targets
    when invoked to perform "cleanup". Files that should not be
    removed during "cleanup" can be specified via the
    &NoClean; method:

  </para>

  <programlisting>
env.Library(target = 'libfoo.a', source = ['aaa.c', 'bbb.c', 'ccc.c'])
env.NoClean('libfoo.a')
  </programlisting>

  <para>

    The NoClean operation has precedence over the Clean operation.
    A target that is specified as both Clean and NoClean, will not
    be removed during a clean.

    In the following example, target 'foo' will not be removed
    during "cleanup":

    <programlisting>
env.Clean(target = 'foo')
env.NoClean('foo')
    </programlisting>

  </para>

  <title>Suppressing build-target removal</title>

  <para>

   As mentioned, by default, &SCons; explicitly removes a target
   file before invoking the underlying function or command(s) to build
   it.  Files that should not be removed before rebuilding can be
   specified via the &Precious; method:

  </para>

	<programlisting>
	env.Library(target = 'libfoo.a', source = ['aaa.c', 'bbb.c', 'ccc.c'])
	env.Precious('libfoo.a')
	</programlisting>

  <title>Default targets</title>

  <para>

   The user may specify default targets that will be built if there are no
   targets supplied on the command line:

  </para>

	<programlisting>
	env.Default('install', 'src')
	</programlisting>

  <para>

   Multiple calls to the &Default; method (typically one per &SConscript;
   file) append their arguments to the list of default targets.

  </para>

  <title>File installation</title>

  <para>

   Files may be installed in a destination directory:

  </para>

	<programlisting>
	env.Install('/usr/bin', 'program1', 'program2')
	</programlisting>

  <para>

   Files may be renamed on installation:

  </para>

	<programlisting>
	env.InstallAs('/usr/bin/xyzzy', 'xyzzy.in')
	</programlisting>

  <para>

   Multiple files may be renamed on installation by specifying
   equal-length lists of target and source files:

  </para>

	<programlisting>
	env.InstallAs(['/usr/bin/foo', '/usr/bin/bar'],
	                ['foo.in', 'bar.in'])
	</programlisting>

  <title>Target aliases</title>

  <para>

   In order to provide convenient "shortcut" target names that expand to
   a specified list of targets, aliases may be established:

  </para>

	<programlisting>
	env.Alias(alias = 'install',
	          targets = ['/sbin', '/usr/lib', '/usr/share/man'])
	</programlisting>

  <para>

   In this example, specifying a target of <literal>install</literal>
   will cause all the files in the associated directories to be built
   (that is, installed).

  </para>

  <para>

   An &Alias; may include one or more other &Aliases; in its list:

  </para>

	<programlisting>
	env.Alias(alias = 'libraries', targets = ['lib'])
	env.Alias(alias = 'programs', targets = ['libraries', 'src'])
	</programlisting>

 <title>Customizing output</title>

 <para>

  The &SCons; API supports the ability to customize, redirect, or
  suppress its printed output through user-defined functions.
  &SCons; has several pre-defined points in its build process at
  which it calls a function to (potentially) print output.  User-defined
  functions can be specified for these call-back points when &Build;
  or &Clean;is invoked:

 </para>

	<programlisting>
	env.Build(target = '.',
	       on_analysis = dump_dependency,
	       pre_update = my_print_command,
	       post_update = my_error_handler)
	       on_error = my_error_handler)
	</programlisting>

 <para>

  The specific call-back points are:

 </para>

 <variablelist>

  <varlistentry>
   <term><literal>on_analysis</literal></term>
   <listitem>
    <para>

     Called for every object, immediately after the object has been
     analyzed to see if it's out-of-date.  Typically used to print a
     trace of considered objects for debugging of unexpected dependencies.

    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><literal>pre_update</literal></term>
   <listitem>
    <para>

     Called for every object that has been determined to be out-of-date
     before its update function or command is executed.  Typically used
     to print the command being called to update a target.

    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><literal>post_update</literal></term>
   <listitem>
    <para>

     Called for every object after its update function or command has
     been executed.  Typically used to report that a top-level specified
     target is up-to-date or was not remade.

    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><literal>on_error</literal></term>
   <listitem>
    <para>

     Called for every error returned by an update function or command.
     Typically used to report errors with some string that will be
     identifiable to build-analysis tools.

    </para>
   </listitem>
  </varlistentry>

 </variablelist>

 <para>

  Functions for each of these call-back points all take the same
  arguments:

 </para>

	<programlisting>
	my_dump_dependency(target, level, status, update, dependencies)
	</programlisting>

 <para>

  where the arguments are:

 </para>

 <variablelist>

  <varlistentry>
   <term><literal>target</literal></term>
   <listitem>
    <para>

     The target object being considered.

    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><literal>level</literal></term>
   <listitem>
    <para>

     Specifies how many levels the dependency analysis has
     recursed in order to consider the <literal>target</literal>.
     A value of <literal>0</literal> specifies a top-level
     <literal>target</literal> (that is, one passed to the
     &Build; or &Clean; method).  Objects which a top-level
     <literal>target</literal> is directly dependent upon have a
     <literal>level</literal> of <1>, their direct dependencies have a
     <literal>level</literal> of <2>, etc.  Typically used to indent
     output to reflect the recursive levels.

    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><literal>status</literal></term>
   <listitem>
    <para>

     A string specifying the current status of the target
     (<literal>"unknown"</literal>, <literal>"built"</literal>,
     <literal>"error"</literal>, <literal>"analyzed"</literal>, etc.).  A
     complete list will be enumerated and described during implementation.

    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><literal>update</literal></term>
   <listitem>
    <para>

     The command line or function name that will be (or has been) executed
     to update the <literal>target</literal>.

    </para>
   </listitem>
  </varlistentry>

  <varlistentry>
   <term><literal>dependencies</literal></term>
   <listitem>
    <para>

     A list of direct dependencies of the target.

    </para>
   </listitem>
  </varlistentry>

 </variablelist>

 <title>Separate source and build trees</title>

 <para>

  &SCons; allows target files to be built completely separately from
  the source files by "linking" a build directory to an underlying
  source directory:

 </para>

	<programlisting>
	env.Link('build', 'src')

	SConscript('build/SConscript')
	</programlisting>

 <para>

  &SCons; will copy (or hard link) necessary files (including the
  &SConscript; file) into the build directory hierarchy.  This allows the
  source directory to remain uncluttered by derived files.

 </para>

 <title>Variant builds</title>

 <para>

  The &Link; method may be used in conjunction with multiple
  &consenvs; to support variant builds.  The following
  &SConstruct; and &SConscript; files would build separate debug and
  production versions of the same program side-by-side:

 </para>

	<programlisting>
	% cat SConstruct
	env = Environment()
	env.Link('build/debug', 'src')
	env.Link('build/production', 'src')
	flags = '-g'
	SConscript('build/debug/SConscript', Export(env))
	flags = '-O'
	SConscript('build/production/SConscript', Export(env))
	% cat src/SConscript
	env = Environment(CCFLAGS = flags)
	env.Program('hello', 'hello.c')
	</programlisting>

 <para>

  The following example would build the appropriate program for the current
  compilation platform, without having to clean any directories of object
  or executable files for other architectures:

 </para>

	<programlisting>
	% cat SConstruct
	build_platform = os.path.join('build', sys.platform)
	Link(build_platform, 'src')
	SConscript(os.path.join(build_platform, 'SConscript'))
	% cat src/SConscript
	env = Environment
	env.Program('hello', 'hello.c')
	</programlisting>

 <title>Code repositories</title>

 <para>

  &SCons; may use files from one or more shared code repositories in order
  to build local copies of changed target files.  A repository would
  typically be a central directory tree, maintained by an integrator,
  with known good libraries and executables.

 </para>

	<programlisting>
	Repository('/home/source/1.1', '/home/source/1.0')
	</programlisting>

 <para>

  Specified repositories will be searched in-order for any file
  (configuration file, input file, target file) that does not exist
  in the local directory tree.  When building a local target file,
  &SCons; will rewrite path names in the build command to use the
  necessary repository files.  This includes modifying lists of
  <option>-I</option> or <option>-L</option> flags to specify an
  appropriate set of include paths for dependency analysis.

 </para>
 <para>

  &SCons; will modify the Python <varname>sys.path</varname> variable to
  reflect the addition of repositories to the search path, so that any
  imported modules or packages necessary for the build can be found in a
  repository, as well.

 </para>
 <para>

  If an up-to-date target file is found in a code repository, the file
  will not be rebuilt or copied locally.  Files that must exist locally
  (for example, to run tests) may be specified:

 </para>

	<programlisting>
	Local('program', 'libfoo.a')
	</programlisting>

 <para>

  in which case &SCons; will copy or link an up-to-date copy of the
  file from the appropriate repository.

 </para>

 <title>Derived-file caching</title>

 <para>

  &SCons; can maintain a cache directory of target files which may be
  shared among multiple builds.  This reduces build times by allowing
  developers working on a project together to share common target
  files:

 </para>

	<programlisting>
	Cache('/var/tmp/build.cache/i386')
	</programlisting>

 <para>

  When a target file is generated, a copy is added to the cache.
  When generating a target file, if &SCons; determines that a file
  that has been built with the exact same dependencies already exists
  in the specified cache, &SCons; will copy the cached file rather
  than re-building the target.

 </para>
 <para>

  Command-line options exist to modify the &SCons; caching behavior
  for a specific build, including disabling caching, building
  dependencies in random order, and displaying commands as if cached
  files were built.

 </para>

 <title>Job management</title>

 <para>

  A simple API exists to inform the Build Engine how many jobs may
  be run simultaneously:

 </para>

	<programlisting>
	Jobs(limit = 4)
	</programlisting>

</chapter>


text:
<?php

class CommentParserTest extends TestCase {

    public function testCommentTagsAreParsed()
    {
        $parser = new ParserStub;
        $tags = $parser->parse( $this->getComment() );

        $this->assertTrue(is_array($tags));
        $this->assertEquals(3, count($tags));
        $this->assertEquals('fooVar', $tags['getter']);
        $this->assertEquals('barVar', $tags['setter']);
        $this->assertEquals('fooTable', $tags['table']);
    }

    protected function getComment()
    {
        return <<<COMMENT
/**
 * This is a short description.
 *
 * This is a *long* description.
 *
 * @getter fooVar
 * @setter barVar
 * @table fooTable
 */
COMMENT;
    }
}

class ParserStub {
    use EntityMapper\Parser\CommentParser;

    public function parse($comment)
    {
        $comment = $this->cleanInput($comment);
        $tags = $this->splitComment($comment);
        return $this->parseTags($tags);
    }
}

redpajama_set_name: RedPajamaGithub


text:
Gos Notification Angular Application
====================================

About
-----
It's angular application for [Gos Notification Bundle](https://github.com/GeniusesOfSymfony/NotificationBundle) to brings
real time notification, user interface to manage notification (like facebook).

Features
--------

- Notification board UI (read, mask as view)
- Title unread notification
- Real time notification with UI and audio
- Expose the same API that [NotificationCenter](https://github.com/GeniusesOfSymfony/NotificationBundle/blob/master/NotificationCenter.php)

Install
--------

Not yet registered on bower and npm.

```html
<script type="text/javascript" src="notification/dist/gos-notification-dist.js"></script>
```

Development
----------

```cmd
gulp //watch by default
gulp watch //watch less & coffee
gulp less //compile less
gulp browserify //compile angular coffee app
gulp serve //compile browersify and less
```

Production
----------

```cmd
gulp serve --production //use it also when you commit dist folder for PR to update properly files.
```

**This is currently in progress, there are still a lot of work !**


text:
function performRequest (Pnr, htmlParseCallback, verboseOutput) {
  if (verboseOutput) {
    console.log('Processing PNR ' + Pnr);
    console.log('Performing request!');
    console.log((new Date()).toISOString());
    console.log(Pnr);
  }
  var request = require('request');

  var requestUrl = 'http://www.indianrail.gov.in/cgi_bin/inet_pnstat_cgi_10521.cgi';

  var random_digit = parseInt(Math.random() * 89999, 10) + 10000;

  var formData_object = {
    'lccp_cap_val': random_digit,
    'lccp_capinp_val': random_digit,
    'lccp_pnrno1': Pnr,
    'submit': 'Get Status'
  };

  var header_object = {
    'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0',
    'Host': 'www.indianrail.gov.in',
    'Origin': 'http://www.indianrail.gov.in',
    'Referer': 'http://www.indianrail.gov.in/pnr_Enq.html'
  };

	var flushed_pnrs = [];
  request({ method: 'POST', url: requestUrl, form: formData_object, headers: header_object }, function (error, response, body) {
    if (error) {
      console.error(error);
      htmlParseCallback(error);
    } else if (!error && response.statusCode === 200) {
      if (verboseOutput) {
        console.log('Recd ' + body.length + ' bytes from server.');
        console.log('Request completed successfully!');
        console.log((new Date()).toISOString());
        console.log('sending body to html parser');
      }
			if (body.match(/FLUSHED\sPNR/g)) {
				flushed_pnrs.push(Pnr);
			}
      htmlParseCallback(null, body, flushed_pnrs);
    }
  });
}

module.exports.performRequest = performRequest;


text:
from cinder.api.middleware import auth
from cinder.openstack.common import log as logging

LOG = logging.getLogger(__name__)

class CinderKeystoneContext(auth.CinderKeystoneContext):
    def __init__(self, application):
        LOG.warn(_('cinder.api.auth:CinderKeystoneContext is deprecated. '
                   'Please use '
                   'cinder.api.middleware.auth:CinderKeystoneContext '
                   'instead.'))
        super(CinderKeystoneContext, self).__init__(application)

def pipeline_factory(loader, global_conf, **local_conf):
    LOG.warn(_('cinder.api.auth:pipeline_factory is deprecated. Please use '
             'cinder.api.middleware.auth:pipeline_factory instead.'))
    auth.pipeline_factory(loader, global_conf, **local_conf)


text:
namespace cc {

class FakePicturePileImpl : public PicturePileImpl {
 public:
  static scoped_refptr<FakePicturePileImpl> CreateFilledPile(
      gfx::Size tile_size,
      gfx::Size layer_bounds);

  static scoped_refptr<FakePicturePileImpl> CreateEmptyPile(
      gfx::Size tile_size,
      gfx::Size layer_bounds);

  TilingData& tiling() { return tiling_; }

  void AddRecordingAt(int x, int y);
  void RemoveRecordingAt(int x, int y);
  void RerecordPile();

  void AddPictureToRecording(
      int x,
      int y,
      scoped_refptr<Picture> picture);

  void add_draw_rect(const gfx::RectF& rect) {
    client_.add_draw_rect(rect, default_paint_);
  }

  void add_draw_bitmap(const SkBitmap& bitmap, gfx::Point point) {
    client_.add_draw_bitmap(bitmap, point);
  }

  void add_draw_rect_with_paint(const gfx::RectF& rect, const SkPaint& paint) {
    client_.add_draw_rect(rect, paint);
  }

  void set_default_paint(const SkPaint& paint) {
    default_paint_ = paint;
  }

  void set_background_color(SkColor color) {
    background_color_ = color;
  }

  void set_contents_opaque(bool contents_opaque) {
    contents_opaque_ = contents_opaque;
  }

 protected:
  FakePicturePileImpl();
  virtual ~FakePicturePileImpl();

  FakeContentLayerClient client_;
  SkPaint default_paint_;
};

}  // namespace cc

#endif  // CC_TEST_FAKE_PICTURE_PILE_IMPL_H_


text:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.sonatype.oss</groupId>
        <artifactId>oss-parent</artifactId>
        <version>7</version>
    </parent>

    <groupId>com.furnaghan.home</groupId>
    <artifactId>home-parent</artifactId>
    <packaging>pom</packaging>
    <version>0.1-SNAPSHOT</version>

    <modules>
        <module>component</module>

        <module>component-amp-onkyo</module>
        <module>component-calendar-google</module>
        <module>component-clock-system</module>
        <module>component-email-imap</module>
        <module>component-feed-rss</module>
        <module>component-evohome</module>
        <module>component-meter-currentcost</module>
        <module>component-metrics-dropwizard</module>
        <module>component-metrics-librato</module>
        <module>component-metrics-statsd</module>
        <module>component-modem-sky</module>
        <module>component-notifier-logging</module>
        <module>component-ping</module>
        <module>component-littleprinter</module>
        <module>component-router-tomato</module>
        <module>component-storage-local</module>
        <module>component-storage-sftp</module>
        <module>component-torrent-deluge</module>
        <module>component-tv-bravia</module>
        <module>component-xbmc</module>

        <module>policy</module>
        <module>policy-script</module>
        <module>policy-script-groovy</module>
        <module>policy-script-python</module>
        <module>policy-server</module>
        <module>policy-server-store</module>
        <module>policy-server-store-file</module>
        <module>policy-server-web</module>

        <module>type-amp</module>
        <module>type-calendar</module>
        <module>type-clock</module>
        <module>type-email</module>
        <module>type-feed</module>
        <module>type-heating</module>
        <module>type-mediaplayer</module>
        <module>type-medialibrary</module>
        <module>type-meter</module>
        <module>type-metrics</module>
        <module>type-modem</module>
        <module>type-notificationsource</module>
        <module>type-notifier</module>
        <module>type-printer</module>
        <module>type-router</module>
        <module>type-storage</module>
        <module>type-torrent</module>
        <module>type-tv</module>

        <module>utils</module>
    </modules>

    <properties>
        <jdk.version>1.8</jdk.version>

        <dropwizard.version>0.7.1</dropwizard.version>
        <guava.version>18.0</guava.version>
        <jackson.version>2.3.3</jackson.version>

        <hamcrest.version>1.3</hamcrest.version>

        <maven-compiler.version>3.3</maven-compiler.version>
        <maven-resources.version>2.7</maven-resources.version>
        <maven-enforcer.version>1.4</maven-enforcer.version>
        <maven-source.version>2.4</maven-source.version>
        <maven-javadoc.version>2.10.3</maven-javadoc.version>
        <maven-jar.version>2.6</maven-jar.version>

        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <licenses>
        <license>
            <name>Apache License 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Jamie Furness</name>
            <email>jamie@jamierf.co.uk</email>
            <timezone>0</timezone>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git://github.com/reines/home.git</connection>
        <developerConnection>scm:git:git@github.com:reines/home.git</developerConnection>
        <url>https://github.com/reines/home</url>
    </scm>

    <issueManagement>
        <system>GitHub</system>
        <url>https://github.com/reines/home/issues</url>
    </issueManagement>

    <distributionManagement>
        <snapshotRepository>
            <id>sonatype-nexus-snapshots</id>
            <name>Sonatype Nexus Snapshots</name>
            <url>http://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>sonatype-nexus-staging</id>
            <name>Nexus Release Repository</name>
            <url>http://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <dependencies>
        <dependency>
            <groupId>io.dropwizard</groupId>
            <artifactId>dropwizard-testing</artifactId>
            <version>${dropwizard.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>${hamcrest.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler.version}</version>
                <configuration>
                    <source>${jdk.version}</source>
                    <target>${jdk.version}</target>
                    <encoding>${project.build.sourceEncoding}</encoding>
                    <compilerArgument>-parameters</compilerArgument>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>${maven-resources.version}</version>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven-enforcer.version}</version>
                <executions>
                    <execution>
                        <id>enforce</id>
                        <configuration>
                            <rules>
                                <DependencyConvergence/>
                            </rules>
                        </configuration>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>${maven-source.version}</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>${maven-javadoc.version}</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <encoding>${project.build.sourceEncoding}</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>${maven-jar.version}</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <reporting>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-project-info-reports-plugin</artifactId>
                <version>2.7</version>
                <configuration>
                    <dependencyDetailsEnabled>true</dependencyDetailsEnabled>
                    <dependencyLocationsEnabled>true</dependencyLocationsEnabled>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.9.1</version>
                <reportSets>
                    <reportSet>
                        <id>html</id>
                        <reports>
                            <report>javadoc</report>
                        </reports>
                    </reportSet>
                </reportSets>
            </plugin>
        </plugins>
    </reporting>
</project>


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <title>JSDoc: Module: LocalStorageStore</title>

    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">

Module: LocalStorageStore

    LocalStorageStore

The Bikini.LocalStorageStore can be used to store model collection into
the localStorage

Source:

        bikini.js, line 3221

Example

// The LocalStorageStore will save each model data as a json under his id,
// and keeps all id's under an extra key for faster access

var MyCollection = Bikini.Collection.extend({
     store: Bikini.LocalStorageStore.create(),
     entity: 'myEntityName'
});

Extends

Bikini.Store

Index

Modules

Base64

BikiniStore

Collection

Cypher

DataSelector

Date

Entity

Field

LocalStorageStore

Model

ObjectID

Security

SHA256

SqlSelector

Store

UniqueId

WebSqlStore

Classes

Entity

Field

    Documentation generated by JSDoc 3.2.2 on Wed Oct 21 2015 09:22:11 GMT+0200 (CEST)


text:
package me.planetguy.lib.util;

public class LibProperties {

	public static final String modID="planetguyLib";

	public static final String instructionsShowTooltip=modID+".misc.pressShift";

}


text:
#include <qlabel.h>
#include <qtextcodec.h>
#include <ktextbrowser.h>
#include <kcombobox.h>
#include <kurlrequester.h>
#include <kmessagebox.h>
#include <klocale.h>
#include "makedlg.h"
#include "makefrontend.h"
#include "queryview.h"

/** Window flags for call-tree widgets. */
#define MAKE_DLG_W_FLAGS \
	WStyle_Customize | \
	WStyle_NormalBorder | \
	WStyle_Title

/**
 * Class constructor.
 * @param	pParent	The parent widget
 * @param	szName	The widget's name
 */
MakeDlg::MakeDlg(QWidget* pParent, const char* szName) :
	MakeLayout(pParent, szName, MAKE_DLG_W_FLAGS)
{
	// Don't show the "Function" column
	m_pErrorView->setColumnWidthMode(0, QListView::Manual);
	m_pErrorView->setColumnWidth(0, 0);

	// Create a new make front-end
	m_pMake = new MakeFrontend();
	connect(m_pMake, SIGNAL(dataReady(FrontendToken*)), this,
		SLOT(slotShowOutput(FrontendToken*)));
	connect(m_pMake, SIGNAL(finished(uint)), this, SLOT(slotFinished(uint)));
	connect(m_pMake,
		SIGNAL(error(const QString&, const QString&, const QString&)),
		this,
		SLOT(slotAddError(const QString&, const QString&, const QString&)));

	// The Root URL control should browse directories
	m_pRootURL->setMode(KFile::Directory);

	// Handle URL links in the browser
	m_pOutputBrowser->setNotifyClick(true);
	connect(m_pOutputBrowser, SIGNAL(urlClick(const QString&)), this,
		SLOT(slotBrowserClicked(const QString&)));

	// Handle selections in the error view
	connect(m_pErrorView, SIGNAL(lineRequested(const QString& , uint)), this,
		SIGNAL(fileRequested(const QString&, uint)));

	// Do not allow duplicates in the command history
	m_pCommandHistory->setDuplicatesEnabled(false);
}

/**
 * Class destructor.
 */
MakeDlg::~ MakeDlg()
{
	delete m_pMake;
}

/**
 * @return	The currently set make command
 */
QString MakeDlg::getCommand() const
{
	return m_pCommandHistory->currentText();
}

/**
 * @param	sCmd	The new make command to use
 */
void MakeDlg::setCommand(const QString& sCmd)
{
	m_pCommandHistory->setCurrentText(sCmd);
	m_pCommandHistory->addToHistory(sCmd);
}

/**
 * @return	The directory in which to run the make command
 */
QString MakeDlg::getDir() const
{
	return m_pRootURL->url();
}

/**
 * @param	sURL	The new root directory to use
 */
void MakeDlg::setDir(const QString& sURL)
{
	m_pRootURL->setURL(sURL);
}

/**
 * Overrides the default close behaviour.
 * Makes sure that a window is not closed while a make process is running,
 * unless the user explicitly requests it. In this case, the make process
 * is killed.
 * @param	pEvent	The close event descriptor
 */
void MakeDlg::closeEvent(QCloseEvent* pEvent)
{
	// Check if a process is currently running
	if (m_pMake->isRunning()) {
		// Prompt the user
		switch (KMessageBox::questionYesNoCancel(this,
			i18n("A make process is running. Would you like to stop it first?"),
			i18n("Close Make Window"))) {
		case KMessageBox::Yes:
			// Stop the process first
			m_pMake->kill();
			break;

		case KMessageBox::No:
			// Do nothing
			break;

		case KMessageBox::Cancel:
			// Abort closing
			pEvent->ignore();
			return;
		}
	}

	QWidget::closeEvent(pEvent);
}

/**
 * Starts a make process using the user-supplied command.
 * This slot is connected to the clicked() signal of the "Make" button.
 */
void MakeDlg::slotMake()
{
	QString sCommand;

	// Clear the current contents
	m_pOutputBrowser->clear();
	m_pErrorView->clear();

	// Run the make command
	sCommand = m_pCommandHistory->currentText();
	if (!m_pMake->run("make", QStringList::split(" ", sCommand),
		m_pRootURL->url())) {
		KMessageBox::error(this, m_pMake->getRunError());
		return;
	}

	// Add the command to the command history
	m_pCommandHistory->addToHistory(sCommand);

	// Start to caluate make time
	timeMTime.start();
	textLabelMTime->setText("caluating...");

	// Disbale the make button
	m_pMakeButton->setEnabled(false);
	m_pStopButton->setEnabled(true);

	// Display status in main window
	emit makeResult("making...");
}

/**
 * Terminates the current make process.
 * This slot is connected to the clicked() signal of the stop button.
 */
void MakeDlg::slotStop()
{
	m_pMake->kill();
}

/**
 * Displays the parsed output, as generated by the MakeFrontend object.
 * This slot is connected to the dataReady() signal of the make front-end.
 * @param	pToken	Holds the parsed data
 */
void MakeDlg::slotShowOutput(FrontendToken* pToken)
{
	QString sData;

	// GCC uses unicode quote characters - this should ensure that they are
	// treated correctly by the text browser widget
	sData = QTextCodec::codecForLocale()->toUnicode(pToken->getData());
	m_pOutputBrowser->append(sData);
}

/**
 * Displays the results of the make command.
 * This slot is connected to the finished() signal of the make front-end.
 */
void MakeDlg::slotFinished(uint)
{
	// Add "Success" or "Error" at the end of the output
	if (m_pMake->exitStatus() == 0) {
		m_pOutputBrowser->append("Success"
			"");

		// Display status in main window
		emit makeResult("Success.");
	}
	else {
		m_pOutputBrowser->append("Error");

		// Display status in main window
		emit makeResult("Error.");
	}

	// Show make time
	textLabelMTime->setText(QTime(0, 0).addMSecs(timeMTime.elapsed()).toString("hh:mm:ss"));

	// Re-enable the "Make" button
	m_pMakeButton->setEnabled(true);
	m_pStopButton->setEnabled(false);
}

/**
 * Emits the fileRequested() signal when a browser link is clicked.
 * This slot is connected to the urlClick() signal of the browser.
 * @param	sURL	The requested URL
 */
void MakeDlg::slotBrowserClicked(const QString& sURL)
{
	QString sFile;
	QString sLine;

	// Exract the file name and the line number from the URL
	sFile = sURL.section('&', 0, 0);
	sLine = sURL.section('&', 1, 1);

	// Add root path for relative paths
	if (!sFile.startsWith("/"))
		sFile = m_pRootURL->url() + "/" + sFile;

	// Emit the signal
	emit fileRequested(sFile, sLine.toUInt());
}

/**
 * Show an error/warning on a deidicated list.
 * This slot is connected to the error() signal of the make front-end.
 * @param	sFile	The file name containing the error/warning
 * @param	sLine	The line number
 * @param	sText	An explanation of the error
 */
void MakeDlg::slotAddError(const QString& sFile, const QString& sLine,
	const QString& sText)
{
	QString sUniText;

	sUniText = QTextCodec::codecForLocale()->toUnicode(sText);
	m_pErrorView->addRecord("", sFile, sLine, sUniText);

	// Adjust the column width
	m_pErrorView->setColumnWidthMode(0, QListView::Manual);
	m_pErrorView->setColumnWidth(0, 0);
	m_pErrorView->adjustColumn(1);
	m_pErrorView->adjustColumn(2);
	m_pErrorView->adjustColumn(3);
}

#include "makedlg.moc"


text:
title: "May Gardening Tips"
layout: "default"
---

May Gardening Tips

Gardening Information

Prune spring-flowering shrubs such as forsythia, lilac, and quince, as soon as the bloom is finished. Remove older stems, broken, dead, or crossing branches.

Watch for aphids on new growth of roses, perennials, and spiraea. Spray them with a strong stream of water or use an insecticidal soap to control the insects.

Plant trees, shrubs, and perennials obtained from the nursery now. The cool weather and spring rain we usually receive is optimal for new plants.

It is not too late to apply a pre-immergent herbicide to control crabgrass and other annual weeds. Be careful not to use the chemical on vegetable garden or flower beds that will be seeded later as the weather warms.

Cut the spent flowerheads of spring flowering bulbs such as daffodils and tulips. Do not cut back the leaves of these plants until the foliage begins to fade and turn brown since the bulbs need the food produced by the leaves to feed the bulb for next year's bloom.

After the first grass mowing of the season, raise mower blades to their proper cutting height. For Kentucky bluegrass and other cool season turf grasses, that is from 2" to 3" inches high. Keeping the turf grass at this height will promote root growth, conserve water, reduce weeds, and provide for a healthier lawn.

Mulch bare ground to conserve moisture and control weeds.

It is not too late to aerate lawns to improve supply of air, water, and nutrients to turf root systems. Power raking should only be done where extreme amounts of thatch have built up in the turf.

As soon as garden beds are dry enough to allow working the soil, apply and dig in compost or peat moss to increase water-holding ability.

Begin setting out hardier potted plants such as geraniums on decks, porches, and patios. Wait until danger of frost is past to pot-up other tender, less hardy plants. Want to learn about native plants for water conservation, perennial and herb care, or how to use stone in the landscape? Check out our May CALENDAR for useful classes!


text:
<!doctype html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>Mocha Spec Runner</title>
    <link rel="stylesheet" href="lib/mocha/mocha.css">


text:
<?php
/**
  * wechat php test
  */
use Lib\Vendor\SeasLog\Log;
//define your token
define("TOKEN", "kdfkdfk");
$wechatObj = new wechatCallbackapiTest();
if (isset($_GET['echostr'])) {
  $wechatObj->valid();
}else{
  $wechatObj->init_menu();
  $wechatObj->responseMsg();
}

class wechatCallbackapiTest
{
	public function valid()
    {
        $echoStr = $_GET["echostr"];

        //valid signature , option
        if($this->checkSignature()){
        	echo $echoStr;
        	exit;
        }else{
          exit('nonono');
        }
    }

    public function responseMsg()
    {
		//get post data, May be due to the different environments
		$postStr = $GLOBALS["HTTP_RAW_POST_DATA"];

    if (!empty($postStr)){
        $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
        $RX_TYPE = trim($postObj->MsgType);

        switch ($RX_TYPE)
        {
            case "text":
                $resultStr = $this->receiveText1($postObj);
                break;
            case "event":
                $resultStr = $this->receiveEvent($postObj);
                break;
            default:
                $resultStr = "";
                break;
        }
        echo $resultStr;
    }else {
        echo "";
        exit;
    }
  //     	//extract post data
		// if (!empty($postStr)){
  //               /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,
  //                  the best way is to check the validity of xml by yourself */
  //               libxml_disable_entity_loader(true);
  //             	$postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
  //               $fromUsername = $postObj->FromUserName;
  //               $toUsername = $postObj->ToUserName;
  //               $keyword = trim($postObj->Content);
  //               $time = time();
  //               $textTpl = "<xml>
		// 					<ToUserName><![CDATA[%s]]></ToUserName>
		// 					<FromUserName><![CDATA[%s]]></FromUserName>
		// 					<CreateTime>%s</CreateTime>
		// 					<MsgType><![CDATA[%s]]></MsgType>
		// 					<Content><![CDATA[%s]]></Content>
		// 					<FuncFlag>0</FuncFlag>
		// 					</xml>";
		// 		if(!empty( $keyword ))
  //               {
  //             		$msgType = "text";
  //               	$contentStr = "Welcome to wechat world!";
  //               	$resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
  //               	echo $resultStr;
  //               }else{
  //               	echo "Input something...";
  //               }

  //       }else {
  //       	echo "";
  //       	exit;
  //       }
    }

	private function checkSignature()
	{
        // you must define TOKEN by yourself
        if (!defined("TOKEN")) {
            throw new Exception('TOKEN is not defined!');
        }

        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];

		$token = TOKEN;
		$tmpArr = array($token, $timestamp, $nonce);
        // use SORT_STRING rule
		sort($tmpArr, SORT_STRING);
		$tmpStr = implode( $tmpArr );
		$tmpStr = sha1( $tmpStr );

		if( $tmpStr == $signature ){
			return true;
		}else{
			return false;
		}
	}
  private function get_access_token(){
        $appid = "wxb39afc8e3bd62749";
        $appsecret = "8ff4cdfe5cee4b03fc2a88604a0358d6";
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret";

        $output = $this->https_request($url);
        $jsoninfo = json_decode($output, true);

        $access_token = $jsoninfo["access_token"];
        return $access_token;
  }
    function init_menu(){

        $access_token = $this->get_access_token();
        $jsonmenu = '{
              "button":[
              {
                    "name":"天气预报",
                   "sub_button":[
                    {
                       "type":"click",
                       "name":"北京天气",
                       "key":"天气北京"
                    },
                    {
                       "type":"click",
                       "name":"深圳天气",
                       "key":"天气深圳"
                    },
                    {
                        "type":"view",
                        "name":"本地天气",
                        "url":"http://m.hao123.com/a/tianqi"
                    }]

               },
               {
                   "name":"方倍",
                   "sub_button":[
                    {
                    "type": "view",
                    "name": "授权获取",
                    "url": "https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx3a5aac7161b28013&redirect_uri=http%3A%2F%2Fvechat.suoga.org%2Findex.php&response_type=code&scope=snsapi_userinfo&state=1#wechat_redirect"
                    },
                    {
                      "type":"click",
                      "name":"用户信息",
                      "key":"userinfo"
                    },
                    {
                      "type":"view",
                      "name":"授权登录",
                      "url":"http://vechat.suoga.org/login.php"
                    }]

               }]
         }';

        $url = "https://api.weixin.qq.com/cgi-bin/menu/create?access_token=".$access_token;
        $result = $this->https_request($url, $jsonmenu);
        var_dump($result);
    }

        protected function https_request($url,$data = null){
            $curl = curl_init();
            curl_setopt($curl, CURLOPT_URL, $url);
            curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
            curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
            if (!empty($data)){
                curl_setopt($curl, CURLOPT_POST, 1);
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
            }
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
            $output = curl_exec($curl);
            curl_close($curl);
            return $output;
        }
      private function receiveEvent($object)
    {
        $contentStr = "";
        switch ($object->Event)
        {
            case "subscribe":
                $contentStr = "欢迎关注!!!".$object->EventKey;
                Log::info('some',array(),'subscribe');
            case "unsubscribe":

                break;
            case "CLICK":
                switch ($object->EventKey)
                {
                    case "company":
                        $contentStr[] = array("Title" =>"公司简介",
                        "Description" =>"方倍工作室提供移动互联网相关的产品及服务",
                        "PicUrl" =>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg",
                        "Url" =>"weixin://addfriend/pondbaystudio");
                        break;
                    case "userinfo":
                        $res = $this->userinfo($object->FromUserName);
                        $contentStr[] = array('Title'=>'hello','Description'=>$res);
                        break;
                    default:
                        $contentStr[] = array("Title" =>"默认菜单回复",
                        "Description" =>"您正在使用的是方倍工作室的自定义菜单测试接口",
                        "PicUrl" =>"http://discuz.comli.com/weixin/weather/icon/cartoon.jpg",
                        "Url" =>"weixin://addfriend/pondbaystudio");
                        break;
                }
                break;
            case "SCAN":
                // $contentStr = '您扫描了二维码!';
                $contentStr = "扫描 ".$object->EventKey;
                break;
            default:
                $contentStr = '当前事件为:'.$object->Event;
                break;

        }
        if (is_array($contentStr)){
            $resultStr = $this->transmitNews($object, $contentStr);
        }else{
            $resultStr = $this->transmitText($object, $contentStr);
        }
        return $resultStr;
    }

      private function receiveText($object)
    {
        Log::debug($object->Content,array(),'text');

        $token = $this->get_access_token();
        $c=array("query"=>$object->Content,"city"=>"北京","category"=>"stock","appid"=>"wxb39afc8e3bd62749","uid"=>$object->FromUserName);
        $post=json_encode($c);
        $post=urldecode($post);
        //语义理解
        $url = "https://api.weixin.qq.com/semantic/semproxy/search?access_token=".$token;
        $msg = $this->https_request($url,$post);
        $strjson=json_decode($msg);
        $code = $strjson->semantic->details->code;
        $category = $strjson->semantic->details->category;
        $funcFlag = 0;
        $contentStr = "你发送的内容为:".$msg->ret;
        Log::debug($msg->ret,array('msg'=>$msg->ret),'text');
        $resultStr = $this->transmitText($object, $contentStr, $funcFlag);
        return $resultStr;
    }
    private function receiveText1($object)
    {
        Log::debug($object->Content,array(),'text');
        if($object->Content == 'info'){
          $contentStr = 'http://vechat.suoga.org/login.php';
        }else{
          $contentStr = "你发送的内容为:".$object->Content;
        }
        Log::debug($msg->ret,array('msg'=>$object->Content),'text');
        $resultStr = $this->transmitText($object, $contentStr, $funcFlag);
        return $resultStr;
    }
    private function transmitText($object, $content, $funcFlag = 0)
    {
        $textTpl = "<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[text]]></MsgType>
<Content><![CDATA[%s]]></Content>
<FuncFlag>%d</FuncFlag>
</xml>";
        $resultStr = sprintf($textTpl, $object->FromUserName, $object->ToUserName, time(), $content, $funcFlag);
        return $resultStr;
    }
        private function transmitNews($object, $arr_item, $funcFlag = 0)
    {
        //首条标题28字,其他标题39字
        if(!is_array($arr_item))
            return;

        $itemTpl = "    <item>
        <Title><![CDATA[%s]]></Title>
        <Description><![CDATA[%s]]></Description>
        <PicUrl><![CDATA[%s]]></PicUrl>
        <Url><![CDATA[%s]]></Url>
    </item>
";
        $item_str = "";
        foreach ($arr_item as $item)
            $item_str .= sprintf($itemTpl, $item['Title'], $item['Description'], $item['PicUrl'], $item['Url']);

        $newsTpl = "<xml>
<ToUserName><![CDATA[%s]]></ToUserName>
<FromUserName><![CDATA[%s]]></FromUserName>
<CreateTime>%s</CreateTime>
<MsgType><![CDATA[news]]></MsgType>
<Content><![CDATA[]]></Content>
<ArticleCount>%s</ArticleCount>
<Articles>
$item_str</Articles>
<FuncFlag>%s</FuncFlag>
</xml>";

        $resultStr = sprintf($newsTpl, $object->FromUserName, $object->ToUserName, time(), count($arr_item), $funcFlag);
        return $resultStr;
    }
    private function userinfo($openid){
      $access_token = $this->get_access_token();
      return $this->https_request('https://api.weixin.qq.com/cgi-bin/user/info?access_token='.$access_token.'&openid='.$openid);
    }

}

?>


text:
'use strict';

var redisNamespace = require('redis-namespace');
var util = require('./util');

var initPshService = function initPshService(bot, config) {
  var client = redisNamespace.createClient(
    config.redisNamespace,
    config.redisOpts);

  var service = {};

  var getGroupKey = function(group) {
    return util.prefix(
      util.prefix(group, '@'),
      config.redisKeys.groups + ':');
  };

  service.subscribe = function subscribe(user, groups, cb) {
    var added = 0;
    groups.forEach(function(group) {
      client.sadd(getGroupKey(group), user.id);
      client.sadd(config.redisKeys.groups, group, function(err) {
        if (!err) {
          added++;
          if (added === groups.length) {
            cb();
          }
        }
      });
    });
  };

  service.unsubscribe = function unsubscribe(user, groups, cb) {
    var remd = 0;
    groups.forEach(function(group) {
      client.srem(getGroupKey(group), user.id, function(err) {
        if (!err) {
          remd++;
          if (remd === groups.length) {
            cb();
          }
        }
      });
    });
  };

  service.list = function list(cb) {
    client.smembers(config.redisKeys.groups, cb);
  };

  bot.onMessage(function(message, response) {
    // some heuristics for early return
    if (message.text.startsWith('!')) {
      return;
    }

    var words = message.text.split(' ');

    var mentionGroups = words
      .filter(function(s) {
        return s.startsWith('@');
      })
      .filter(function(s) {
        return s.length > 1;
      })
      .reduce(function(acc, mg) {
        acc[mg] || (acc[mg] = []);
        return acc;
      }, {});

    if (Object.keys(mentionGroups).length <= 0) {
      return;
    }

    var responseMsg = message.text;
    var listedGroupsCount = 0;
    Object.keys(mentionGroups).forEach(function(mg) {
      client.smembers(getGroupKey(mg), function(err, mlist) {
        (mlist.length > 0) ?
          (mentionGroups[mg] = mlist) :
          (delete mentionGroups[mg]);
        listedGroupsCount++;

        if (listedGroupsCount === Object.keys(mentionGroups).length) {
          var res = words.reduce(function(acc, word) {
            mentionGroups[word] && (acc.shouldRespond = true);
            if (mentionGroups[word]) {
              mentionGroups[word].forEach(function(id) {
                acc.combinedMentions.add(id);
              });
            }
            else {
              acc.body.push(util.mentionAllSet(acc.combinedMentions));
              acc.body.push(word);
              acc.combinedMentions.clear();
            }
            return acc;
          }, {
            shouldRespond: false,
            body: [],
            combinedMentions: new Set()
          });
          res.combinedMentions.size &&
            res.body.push(util.mentionAllSet(res.combinedMentions));
          res.shouldRespond && response.end(res.body.join(' '));
        }
      });
    });
  });

  return service;
};

initPshService.metadata = require('./service');
module.exports = initPshService;


text:
All notable changes to this project will be documented in this file. This change log follows the conventions of [keepachangelog.com](http://keepachangelog.com/).

## [Unreleased]
### Added
- [e7bcdb4](https://github.com/jvtrigueros/abq-transit/pull/1) - A simple ABQ Transit KML parser.

[Unreleased]: https://github.com/jvtrigueros/abq-transit-utilities/compare/master...HEAD


text:
from muntjac.api import Upload, ProgressIndicator

from muntjac.demo.sampler.APIResource import APIResource
from muntjac.demo.sampler.Feature import Feature, Version

class ImmediateUpload(Feature):

    def getSinceVersion(self):
        return Version.V62

    def getDescription(self):
        return ('The upload component can be configured to work as a '
            'single-click upload, that starts right after the user has '
            'selected the file to upload.

In this sample the '
            'upload is deliberately slow, so that even small files show '
            'the progress indicator.')

    def getName(self):
        return 'Single-click upload'

    def getRelatedAPI(self):
        return [APIResource(Upload), APIResource(ProgressIndicator)]

    def getRelatedFeatures(self):

        from muntjac.demo.sampler.features.upload.UploadBasic import UploadBasic
        from muntjac.demo.sampler.features.upload.UploadWithProgressMonitoring import UploadWithProgressMonitoring

        return [UploadBasic, UploadWithProgressMonitoring]

    def getRelatedResources(self):
        # TODO Auto-generated method stub
        return None


text:
package x509util

import (
	"crypto/sha256"
	"encoding/pem"
	"errors"
	"fmt"
	"os"

	"github.com/google/certificate-transparency-go/x509"
	"k8s.io/klog/v2"
)

// String for certificate blocks in BEGIN / END PEM headers
const pemCertificateBlockType string = "CERTIFICATE"

// PEMCertPool is a wrapper / extension to x509.CertPool. It allows us to access the
// raw certs, which we need to serve get-roots request and has stricter handling on loading
// certs into the pool. CertPool ignores errors if at least one cert loads correctly but
// PEMCertPool requires all certs to load.
type PEMCertPool struct {
	// maps from sha-256 to certificate, used for dup detection
	fingerprintToCertMap map[[sha256.Size]byte]x509.Certificate
	rawCerts             []*x509.Certificate
	certPool             *x509.CertPool
}

// NewPEMCertPool creates a new, empty, instance of PEMCertPool.
func NewPEMCertPool() *PEMCertPool {
	return &PEMCertPool{fingerprintToCertMap: make(map[[sha256.Size]byte]x509.Certificate), certPool: x509.NewCertPool()}
}

// AddCert adds a certificate to a pool. Uses fingerprint to weed out duplicates.
// cert must not be nil.
func (p *PEMCertPool) AddCert(cert *x509.Certificate) {
	fingerprint := sha256.Sum256(cert.Raw)
	_, ok := p.fingerprintToCertMap[fingerprint]

	if !ok {
		p.fingerprintToCertMap[fingerprint] = *cert
		p.certPool.AddCert(cert)
		p.rawCerts = append(p.rawCerts, cert)
	}
}

// Included indicates whether the given cert is included in the pool.
func (p *PEMCertPool) Included(cert *x509.Certificate) bool {
	fingerprint := sha256.Sum256(cert.Raw)
	_, ok := p.fingerprintToCertMap[fingerprint]
	return ok
}

// AppendCertsFromPEM adds certs to the pool from a byte slice assumed to contain PEM encoded data.
// Skips over non certificate blocks in the data. Returns true if all certificates in the
// data were parsed and added to the pool successfully and at least one certificate was found.
func (p *PEMCertPool) AppendCertsFromPEM(pemCerts []byte) (ok bool) {
	for len(pemCerts) > 0 {
		var block *pem.Block
		block, pemCerts = pem.Decode(pemCerts)
		if block == nil {
			break
		}
		if block.Type != pemCertificateBlockType || len(block.Headers) != 0 {
			continue
		}

		cert, err := x509.ParseCertificate(block.Bytes)
		if x509.IsFatal(err) {
			klog.Warningf("error parsing PEM certificate: %v", err)
			return false
		}

		p.AddCert(cert)
		ok = true
	}

	return
}

// AppendCertsFromPEMFile adds certs from a file that contains concatenated PEM data.
func (p *PEMCertPool) AppendCertsFromPEMFile(pemFile string) error {
	pemData, err := os.ReadFile(pemFile)
	if err != nil {
		return fmt.Errorf("failed to load PEM certs file: %v", err)
	}

	if !p.AppendCertsFromPEM(pemData) {
		return errors.New("failed to parse PEM certs file")
	}
	return nil
}

// Subjects returns a list of the DER-encoded subjects of all of the certificates in the pool.
func (p *PEMCertPool) Subjects() (res [][]byte) {
	return p.certPool.Subjects()
}

// CertPool returns the underlying CertPool.
func (p *PEMCertPool) CertPool() *x509.CertPool {
	return p.certPool
}

// RawCertificates returns a list of the raw bytes of certificates that are in this pool
func (p *PEMCertPool) RawCertificates() []*x509.Certificate {
	return p.rawCerts
}


text:
package me.lucko.luckperms.api.event.events;

import me.lucko.luckperms.api.PermissionHolder;
import me.lucko.luckperms.api.event.AbstractPermissionRemoveEvent;

/**
 * Called whenever a user or group has a permission unset.
 * @deprecated in favour of {@link PermissionNodeUnsetEvent}
 */
@Deprecated
public class PermissionUnsetEvent extends AbstractPermissionRemoveEvent {

    private final String node;

    public PermissionUnsetEvent(PermissionHolder target, String node, String server, String world, boolean temporary) {
        super("Permission Unset Event", target, server, world, temporary);
        this.node = node;
    }

    public String getNode() {
        return node;
    }
}


text:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace ColorPicker
{
    public partial class AboutForm : Form
    {
        public AboutForm(string version)
        {
            InitializeComponent();
            lblVersion.Text = version;
        }
    }
}


text:
import { icon } from '../../marker-icons.js';

import EVENTS from '../../event-names.js';

var size = 1;
var userAgent = navigator.userAgent.toLowerCase();

if (userAgent.indexOf('ipad') !== -1 || userAgent.indexOf('iphone') !== -1) {
  size = 2;
}

export default L.Marker.extend({
  _draggable: undefined, // an instance of L.Draggable
  _oldLatLngState: undefined,
  initialize(group, latlng, options = {}) {

    options = Object.assign({
      icon: icon,
      draggable: false
    }, options);

    L.Marker.prototype.initialize.call(this, latlng, options);

    this._mGroup = group;

    this._isFirst = group.getLayers().length === 0;
  },

  enableDrag() {
    this.dragging.enable();
  },
  disableDrag() {
    this.dragging.disable();
  },
  group() {
    return this._mGroup;
  },

  next() {
    var next = this._next._next;
    if (!this._next.isMiddle()) {
      next = this._next;
    }
    return next;
  },
  prev() {
    var prev = this._prev._prev;
    if (!this._prev.isMiddle()) {
      prev = this._prev;
    }
    return prev;
  },
  changePrevNextPos() {
    if (this._prev.isMiddle()) {

      var prevLatLng = this.group()._getMiddleLatLng(this.prev(), this);
      var nextLatLng = this.group()._getMiddleLatLng(this, this.next());

      this._prev.setLatLng(prevLatLng);
      this._next.setLatLng(nextLatLng);
    }
  },
  _resetIcon(_icon) {
    if (this._hasFirstIcon()) {
      return;
    }
    var ic = _icon || icon;

    this.setIcon(ic);
    this.prev().setIcon(ic);
    this.next().setIcon(ic);
  },

  _addIconClass(className) {
    L.DomUtil.addClass(this._icon, className);
  },
  _removeIconClass(className) {
    L.DomUtil.removeClass(this._icon, className);
  },
  _hasFirstIcon() {
    return this._icon && L.DomUtil.hasClass(this._icon, 'm-editor-div-icon-first');
  },
  isMiddle() {
    return this._icon && L.DomUtil.hasClass(this._icon, 'm-editor-middle-div-icon')
      && !L.DomUtil.hasClass(this._icon, 'leaflet-drag-target');
  },
  _setDragIcon() {
    this._removeIconClass('m-editor-div-icon');
    this._removeIconClass('m-editor-middle-div-icon');
    this._addIconClass('m-editor-div-icon-drag');

    this.update();
  },
  isPlain() {
    return L.DomUtil.hasClass(this._icon, 'm-editor-div-icon');
  },
  _onceClick() {
    if (this._isFirst) {
      this.once('click', (e) => {
        if (!this._hasFirstIcon()) {
          return;
        }
        const map = this._map;
        const mGroup = this.group();

        if (mGroup._markers.length < 3) {
          this._onceClick();
          return;
        }

        this._isFirst = false;
        this.setIcon(icon);
        map.fire(EVENTS.join_path, {mGroup: mGroup});
      });
    }
  },
  isAcceptedToDelete() {
    return this._map.options.notifyClickMarkerDeletePolygon &&
      !this.isMiddle() &&
      this.isSelectedInGroup() &&
      this._map.getSelectedMarker() === this &&
      this.group().hasMinimalMarkersLength();
  },
  needAcceptToDelete() {
    return this._map.options.notifyClickMarkerDeletePolygon &&
      !this.isMiddle() &&
      this.isSelectedInGroup() &&
      this._map.getSelectedMarker() !== this &&
      this.group().hasMinimalMarkersLength();
  },
  _disallowToExecuteEvent() {
    const map = this._map;
    let selectedMGroup;

    if (map) {
      selectedMGroup = map.getSelectedMGroup()
    }

    return selectedMGroup && selectedMGroup.hasFirstMarker() && selectedMGroup !== this.group();
  },
  _bindEvents() {

    this.on('dragstart', e => {
      this._setDragIcon();

      this.group().setSelected(this);
      this._oldLatLngState = e.target._latlng;

      if (this._prev.isPlain()) {
        this.group().setMiddleMarkers(this.position);
      }

      this._map.fire(EVENTS.marker_dragstart);

      this.__dragging = true;
    });

    this.on('click', () => {
      const mGroup = this.group();
      const map = this._map;

      if (this._disallowToExecuteEvent()) {
        return;
      }

      if (this.needAcceptToDelete()) {
        mGroup.setSelected(this);
        map.msgHelper.msg(map.options.text.acceptDeletion, 'error', this);
        return;
      }

      if (mGroup.hasFirstMarker() && this !== mGroup.getFirst()) {
        return;
      }

      if (this._hasFirstIcon()) {
        return;
      }

      mGroup.setSelected(this);
      if (this._hasFirstIcon()) {
        return;
      }

      if (mGroup.getFirst()._hasFirstIcon()) {
        return;
      }

      if (!this.isSelectedInGroup()) {
        mGroup.select();

        if (this.isMiddle()) {
          map.msgHelper.msg(map.options.text.clickToAddNewEdges, null, this);
        } else {
          map.msgHelper.msg(map.options.text.clickToRemoveAllSelectedEdges, null, this);
        }

        if (this.isAcceptedToDelete()) {
          map.msgHelper.msg(map.options.text.acceptDeletion, 'error', this);
        }

        return;
      }

      if (this.isMiddle()) { //add vertex
        mGroup.setMiddleMarkers(this.position);
        this._resetIcon(icon);
        mGroup.select();
        map.msgHelper.msg(map.options.text.clickToRemoveAllSelectedEdges, null, this);

        map.clearSelectedMarker();

      } else { //remove vertex
        if (!mGroup.getFirst()._hasFirstIcon()) {
          map.msgHelper.hide();

          mGroup.removeMarker(this);

          if (mGroup.isEmpty()) {
            if (mGroup._isHole) {
              map.fire(EVENTS.hole_deleted);
            } else {
              map.fire(EVENTS.polygon_deleted);
            }
            map.msgHelper.hide();
          }
          mGroup.select();
        }
      }
    });

    this.on('mousedown', () => {
      if (!this.dragging._enabled) {
        return false;
      }
    });

    this.on('mouseover', (e) => {
      e.originalEvent.stopPropagation();

      const selectedMarker = this._map.getSelectedMarker();
      const selectedMarkerDragging = !!(selectedMarker && selectedMarker.__dragging);

      if (this._disallowToExecuteEvent() || selectedMarkerDragging) {
        return;
      }

      const map = this._map;
      if (this.group().getFirst()._hasFirstIcon()) {
        if (this.group().getLayers().length > 2) {
          if (this._hasFirstIcon()) {
            map.fire(EVENTS.first_marker_mouseover, {marker: this});
          } else if (this === this.group()._lastMarker) {
            map.fire(EVENTS.last_marker_dblclick_mouseover, {marker: this});
          }
        }
      } else {
        if (this.isSelectedInGroup()) {
          if (this.isMiddle()) {
            map.fire(EVENTS.selected_middle_marker_mouseover, {marker: this});
          } else {
            map.fire(EVENTS.selected_marker_mouseover, {marker: this});
          }
        } else {
          map.fire(EVENTS.not_selected_marker_mouseover, {marker: this});
        }
      }
      if (this.isAcceptedToDelete()) {
        map.msgHelper.msg(map.options.text.acceptDeletion, 'error', this);
      }
    });
    this.on('mouseout', (e) => {
      e.originalEvent.stopPropagation();

      const selectedMarker = this._map.getSelectedMarker();
      const selectedMarkerDragging = !!(selectedMarker && selectedMarker.__dragging);

      if (this._disallowToExecuteEvent() || selectedMarkerDragging) {
        return;
      }

      this._map.fire(EVENTS.marker_mouseout);
    });

    this._onceClick();

    this.on('dblclick', () => {
      if (this._disallowToExecuteEvent()) {
        return;
      }

      var mGroup = this.group();
      if (mGroup && mGroup.getFirst() && mGroup.getFirst()._hasFirstIcon()) {
        if (this === mGroup._lastMarker) {
          mGroup.getFirst().fire('click');
        }
      }
    });

    this.on('drag', (e) => {
      this._onDrag(e);
    });

    this.on('dragend', (e) => {
      this._onDragEnd(e);
    });
  },

  onAdd(map) {
    L.Marker.prototype.onAdd.call(this, map);

    this._bindEvents(map);
  },
  _onDrag(e) {
    const marker = e.target;

    marker.changePrevNextPos();

    const map = this._map;
    map._convertToEdit(map.getEMarkersGroup());

    this._setDragIcon();

    map.fire(EVENTS.drag_marker, {marker: this});
  },
  _onDragEnd() {
    setTimeout(() => {
      this.group().select();
      this._map.fire(EVENTS.dragend_marker, {marker: this});

      this._map.fire(EVENTS.selected_marker_mouseover, {marker: this});

      this.resetStyle();
    }, 1);
  },
  resetIcon() {
    this._removeIconClass('m-editor-div-icon-drag');
  },
  unSelectIconInGroup() {
    this._removeIconClass('group-selected');
  },
  _selectIconInGroup() {
    if (!this.isMiddle()) {
      this._addIconClass('m-editor-div-icon');
    }
    this._addIconClass('group-selected');
  },
  selectIconInGroup() {
    if (this._prev) {
      this._prev._selectIconInGroup();
    }
    this._selectIconInGroup();
    if (this._next) {
      this._next._selectIconInGroup();
    }
  },
  isSelectedInGroup() {
    return L.DomUtil.hasClass(this._icon, 'group-selected');
  },
  onRemove(map) {
    this.off('mouseout');

    L.Marker.prototype.onRemove.call(this, map);
  },

  resetStyle() {
    this.resetIcon();
    this.selectIconInGroup();
  }
});