Add Mac OS X support.
337636
def _darwin_current_arch(self):
        """"""
        if sys.platform == "darwin":
            if sys.maxsize > 2 ** 32: # 64bits.
                return platform.mac_ver()[2] # Both Darwin and Python are 64bits.
            else: # Python 32 bits
                return platform.processor()
982127
def touch(path):
    """"""
    import os
    try:
        OPEN_FUNC(path, 'a+').close()
    except IOError:
        os.utime(path, None)
1112507
function addToWhiteList(aDomain) { 
  pm.add(utils.createURI(aDomain),
         "install",
         Ci.nsIPermissionManager.ALLOW_ACTION);
}
336328
public static void setup() {
        // Set the various and sundry OS X-specific system properties
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("dock:name", "ZAP"); // Broken and unfixed; thanks, Apple
        System.setProperty("com.apple.mrj.application.apple.menu.about.name", "ZAP"); // more thx

        // Override various handlers, so that About, Preferences, and Quit behave in an OS X typical fashion.
        LOGGER.info("Initializing OS X specific settings, despite Apple's best efforts");

        // TODO Remove the menu item File -> Exit, redundant with quit handler.

        try {
            InvocationHandler invocationHandler = (o, m, args) -> {
                // Same method names for both APIs.
                switch (m.getName()) {
                case "handleAbout":
                    showAboutDialog();
                    break;
                case "handlePreferences":
                    showOptionsDialog();
                    break;
                case "handleQuitRequestWith":
                    exitZap();
                    break;
                }
                return null;
            };

            if (SystemUtils.IS_JAVA_1_8) {
                // TODO Remove once targeting Java 9+ (and stop using reflection).
                setupJava8(invocationHandler);
            } else {
                setupJava9Plus(invocationHandler);
            }
        } catch (Throwable e) {
            LOGGER.error("Failed to set up all macOS GUI changes:", e);
        }
    }
1236109
async def add(gc: GroupControl, slaves):
    """"""
    click.echo("Adding to existing group: %s" % slaves)
    click.echo(await gc.add(slaves))
570492
def add(modname, features, required_version, installed_version=None,
        optional=False):
    """"""
    global DEPENDENCIES
    for dependency in DEPENDENCIES:
        if dependency.modname == modname:
            raise ValueError("Dependency has already been registered: %s"\
                             % modname)
    DEPENDENCIES += [Dependency(modname, features, required_version,
                                installed_version, optional)]
490722
def connect(self, mac: str):
        """"""
        import pygatt

        address_type = pygatt.BLEAddressType.public
        if self._address_type == 'random':
            address_type = pygatt.BLEAddressType.random
        self._device = self._adapter.connect(mac, address_type=address_type)
1374021
def add_on_cpu(self, transforms):
        """"""
        if not isinstance(transforms, list):
            transforms = [transforms]
        self.cpu_transforms.extend(transforms or [])
        return self
660140
async def add(ctx, left: int, right: int):
    """"""
    await ctx.send(left + right)
546745
def upgrade():
    """"""
    op.drop_constraint('fk_oauth2server_client_user_id_accounts_user',
                       'oauth2server_client', type_='foreignkey')
    op.create_foreign_key(op.f('fk_oauth2server_client_user_id_accounts_user'),
                          'oauth2server_client', 'accounts_user', ['user_id'],
                          ['id'], ondelete='CASCADE')
    op.create_index(op.f('ix_oauth2server_client_user_id'),
                    'oauth2server_client', ['user_id'], unique=False)
    op.drop_constraint('fk_oauth2server_token_user_id_accounts_user',
                       'oauth2server_token', type_='foreignkey')
    op.create_foreign_key(op.f('fk_oauth2server_token_user_id_accounts_user'),
                          'oauth2server_token', 'accounts_user', ['user_id'],
                          ['id'], ondelete='CASCADE')
    op.create_index(op.f('ix_oauth2server_token_user_id'),
                    'oauth2server_token', ['user_id'], unique=False)
    op.drop_constraint('fk_oauth2server_token_client_id_oauth2server_client',
                       'oauth2server_token', type_='foreignkey')
    op.create_foreign_key(
        op.f('fk_oauth2server_token_client_id_oauth2server_client'),
        'oauth2server_token', 'oauth2server_client', ['client_id'],
        ['client_id'], ondelete='CASCADE')
    op.create_index(op.f('ix_oauth2server_token_client_id'),
                    'oauth2server_token', ['client_id'], unique=False)
1000639
def get_darwin_arches(major, minor, machine):
    
    arches = []

    def _supports_arch(major, minor, arch):
        # Looking at the application support for macOS versions in the chart
        # provided by https://en.wikipedia.org/wiki/OS_X#Versions it appears
        # our timeline looks roughly like:
        #
        # 10.0 - Introduces ppc support.
        # 10.4 - Introduces ppc64, i386, and x86_64 support, however the ppc64
        #        and x86_64 support is CLI only, and cannot be used for GUI
        #        applications.
        # 10.5 - Extends ppc64 and x86_64 support to cover GUI applications.
        # 10.6 - Drops support for ppc64
        # 10.7 - Drops support for ppc
        #
        # Given that we do not know if we're installing a CLI or a GUI
        # application, we must be conservative and assume it might be a GUI
        # application and behave as if ppc64 and x86_64 support did not occur
        # until 10.5.
        #
        # Note: The above information is taken from the "Application support"
        #       column in the chart not the "Processor support" since I believe
        #       that we care about what instruction sets an application can use
        #       not which processors the OS supports.
        if arch == 'ppc':
            return (major, minor) <= (10, 5)
        if arch == 'ppc64':
            return (major, minor) == (10, 5)
        if arch == 'i386':
            return (major, minor) >= (10, 4)
        if arch == 'x86_64':
            return (major, minor) >= (10, 5)
        if arch in groups:
            for garch in groups[arch]:
                if _supports_arch(major, minor, garch):
                    return True
        return False

    groups = OrderedDict([
        ("fat", ("i386", "ppc")),
        ("intel", ("x86_64", "i386")),
        ("fat64", ("x86_64", "ppc64")),
        ("fat32", ("x86_64", "i386", "ppc")),
    ])

    if _supports_arch(major, minor, machine):
        arches.append(machine)

    for garch in groups:
        if machine in groups[garch] and _supports_arch(major, minor, garch):
            arches.append(garch)

    arches.append('universal')

    return arches
306194
def add(self, iocb):
        """"""
        if _debug: IOGroup._debug("add %r", iocb)

        # add this to our members
        self.ioMembers.append(iocb)

        # assume all of our members have not completed yet
        self.ioState = PENDING
        self.ioComplete.clear()

        # when this completes, call back to the group.  If this
        # has already completed, it will trigger
        iocb.add_callback(self.group_callback)
972690
def addpath(path):
    """"""
    import sys
    if not exists(path):
        raise ValueError('Path %s does not exist' % path)
    sys.path.insert(1, path)
1017032
def init_app(self, app):
        """"""
        app.cli.add_command(upgrader_cmd)
        app.extensions['invenio-upgrader'] = self
32548
public function boot()
    {
        PresetCommand::macro('uikit', function ($command) {
            UIkitPreset::install();
            $command->info('UIkit 3 scaffolding installed successfully.');
            $command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
        });

        PresetCommand::macro('uikit-auth', function ($command) {
            UIkitPreset::installAuth();
            $command->info('UIkit 3 scaffolding with auth views installed successfully.');
            $command->info('Please run "npm install && npm run dev" to compile your fresh scaffolding.');
        });
    }
1371593
def upgrade():
    """"""
    with op.batch_alter_table('accounts_user_session_activity') as batch_op:
        batch_op.add_column(sa.Column('browser', sa.String(80), nullable=True))
        batch_op.add_column(
            sa.Column('browser_version', sa.String(30), nullable=True))
        batch_op.add_column(
            sa.Column('country', sa.String(3), nullable=True))
        batch_op.add_column(
            sa.Column('device', sa.String(80), nullable=True))
        batch_op.add_column(
            sa.Column('ip', sa.String(80), nullable=True))
        batch_op.add_column(
            sa.Column('os', sa.String(80), nullable=True))
396767
def run(self):
    """"""

    module = self.distribution.ext_modules[0]
    base_dir = os.path.dirname(__file__)

    if base_dir:
      os.chdir(base_dir)

    exclusions = []

    for define in self.define or []:
      module.define_macros.append(define)

    for library in self.libraries or []:
      module.libraries.append(library)

    building_for_windows = self.plat_name in ('win32','win-amd64')
    building_for_osx = 'macosx' in self.plat_name
    building_for_linux = 'linux' in self.plat_name
    building_for_freebsd = 'freebsd' in self.plat_name
    building_for_openbsd = 'openbsd' in self.plat_name # need testing

    if building_for_linux:
      module.define_macros.append(('USE_LINUX_PROC', '1'))
    elif building_for_windows:
      module.define_macros.append(('USE_WINDOWS_PROC', '1'))
      module.define_macros.append(('_CRT_SECURE_NO_WARNINGS', '1'))
      module.libraries.append('kernel32')
      module.libraries.append('advapi32')
      module.libraries.append('user32')
      module.libraries.append('crypt32')
      module.libraries.append('ws2_32')
    elif building_for_osx:
      module.define_macros.append(('USE_MACH_PROC', '1'))
      module.include_dirs.append('/usr/local/opt/openssl/include')
      module.include_dirs.append('/opt/local/include')
      module.library_dirs.append('/opt/local/lib')
      module.include_dirs.append('/usr/local/include')
      module.library_dirs.append('/usr/local/lib')
    elif building_for_freebsd:
      module.define_macros.append(('USE_FREEBSD_PROC', '1'))
      module.include_dirs.append('/opt/local/include')
      module.library_dirs.append('/opt/local/lib')
      module.include_dirs.append('/usr/local/include')
      module.library_dirs.append('/usr/local/lib')
    elif building_for_openbsd:
      module.define_macros.append(('USE_OPENBSD_PROC', '1'))
      module.include_dirs.append('/opt/local/include')
      module.library_dirs.append('/opt/local/lib')
      module.include_dirs.append('/usr/local/include')
      module.library_dirs.append('/usr/local/lib')
    else:
      module.define_macros.append(('USE_NO_PROC', '1'))

    if has_function('memmem'):
      module.define_macros.append(('HAVE_MEMMEM', '1'))
    if has_function('strlcpy'):
      module.define_macros.append(('HAVE_STRLCPY', '1'))
    if has_function('strlcat'):
      module.define_macros.append(('HAVE_STRLCAT', '1'))

    if self.enable_profiling:
      module.define_macros.append(('PROFILING_ENABLED', '1'))

    if self.dynamic_linking:
      module.libraries.append('yara')
    else:
      if not self.define or not ('HASH_MODULE', '1') in self.define:
        if (has_function('MD5_Init', libraries=['crypto']) and
            has_function('SHA256_Init', libraries=['crypto'])):
          module.define_macros.append(('HASH_MODULE', '1'))
          module.define_macros.append(('HAVE_LIBCRYPTO', '1'))
          module.libraries.append('crypto')
        else:
          exclusions.append('yara/libyara/modules/hash.c')

      if self.enable_magic:
        module.define_macros.append(('MAGIC_MODULE', '1'))
        module.libraries.append('magic')
      else:
        exclusions.append('yara/libyara/modules/magic.c')

      if self.enable_cuckoo:
        module.define_macros.append(('CUCKOO_MODULE', '1'))
        module.libraries.append('jansson')
      else:
        exclusions.append('yara/libyara/modules/cuckoo.c')

      if self.enable_dotnet:
        module.define_macros.append(('DOTNET_MODULE', '1'))
      else:
        exclusions.append('yara/libyara/modules/dotnet.c')

      if self.enable_dex:
        module.define_macros.append(('DEX_MODULE', '1'))
      else:
        exclusions.append('yara/libyara/modules/dex.c')

      if self.enable_macho:
        module.define_macros.append(('MACHO_MODULE', '1'))
      else:
        exclusions.append('yara/libyara/modules/macho.c')

      exclusions = [os.path.normpath(x) for x in exclusions]

      for directory, _, files in os.walk('yara/libyara/'):
        for x in files:
          x = os.path.normpath(os.path.join(directory, x))
          if x.endswith('.c') and x not in exclusions:
            module.sources.append(x)

    build_ext.run(self)