Particular pagure projects

     Adding this rule allows you to get notifications for one or more
     `pagure.io <https://pagure.io>`_ projects. Specify multiple
     projects by separating them with a comma ','.
488061
def pagure_specific_project_filter(config, message, project=None, *args, **kw):
    

    if not pagure_catchall(config, message):
        return False

    project = kw.get('project', project)
    link = fedmsg.meta.msg2link(message, **config)
    if not link:
        return False

    project = project.split(',') if project else []

    valid = False
    for proj in project:
        if '://pagure.io/%s/' % proj.strip() in link:
            valid = True

    return valid
759930
def client_list_entries_multi_project(
    client, to_delete
):  # pylint: disable=unused-argument
    """"""

    # [START client_list_entries_multi_project]
    PROJECT_IDS = ["one-project", "another-project"]
    for entry in client.list_entries(project_ids=PROJECT_IDS):  # API call(s)
        do_something_with(entry)
317320
def file_list_projects(object_id, input_params={}, always_retry=True, **kwargs):
    
    return DXHTTPRequest('/%s/listProjects' % object_id, input_params, always_retry=always_retry, **kwargs)
209405
private function admin_page_notices() {
		$display = ( isset( $_GET['updated'] ) && is_multisite() )
				|| isset( $_GET['reset'] )
				|| isset( $_GET['refresh_transients'] );

		if ( $display ) {
			echo '<div class="updated"><p>';
		}
		if ( ( isset( $_GET['updated'] ) && '1' === $_GET['updated'] ) && is_multisite() ) {
			esc_html_e( 'Settings saved.', 'github-updater' );
		} elseif ( isset( $_GET['reset'] ) && '1' === $_GET['reset'] ) {
			esc_html_e( 'RESTful key reset.', 'github-updater' );
		} elseif ( isset( $_GET['refresh_transients'] ) && '1' === $_GET['refresh_transients'] ) {
			esc_html_e( 'Cache refreshed.', 'github-updater' );
		}
		if ( $display ) {
			echo '</p></div>';
		}
	}
1100623
def add_tcp_firewall_rule(project, access_token, name, tag, port):
    """"""
    
    headers = {
        'Authorization': 'Bearer %s' % access_token.access_token
    }
    
    payload = {
        "name": name,
        "kind": "compute#firewall",
        "sourceRanges": [ "0.0.0.0/0" ],
        "targetTags": [ tag ],
        "allowed": [ { "IPProtocol": "tcp", "ports": [ str(port), ] } ],
        "network": "projects/%s/global/networks/default" % project
    }
    
    r = requests.post('https://www.googleapis.com/compute/v1/'
                      'projects/%s/global/firewalls'
                      % project, headers=headers, json=payload)
    r.raise_for_status()
    op = r.json()['name']

    LOGGER.info('Requested to add firewall rule for tag "%s" '
                '(operation "%s")...', tag, op)

    return op
997001
public static function routes()
    {
        $area = area();
        Route::post($area . '/notifications/notifications', NotificationController::class . '@index');
        Route::post($area . '/notifications/widgets/send', NotificationController::class . '@send');
    }
494903
def add_triple_pattern(tp, collector, args):
    
    tp_parts = [part.strip() for part in tp.strip().split(' ')]
    tp = ' '.join(tp_parts)
    if tp not in __triple_patterns.keys():
        __triple_patterns[tp] = set([])
    if collector is not None:
        __triple_patterns[tp].add((collector, args))
1010222
def compat_pagination_messages(cls):
    
    if DRFVLIST[0] == 3 and DRFVLIST[1] >= 1:
        setattr(cls, "pagination_class", MessagePagination)
        return cls
    else:
        # DRF 2 pagination
        setattr(cls, "paginate_by", getattr(settings, "DJANGO_REST_MESSAGING_MESSAGES_PAGE_SIZE", 30))
        return cls
15245
def notify(*options, &block)
      raise "Couldn't create notifications without a block" unless block_given?

      conditions = *options
      conditions = DEFAULT_NOTIFICATIONS if options.empty?

      conditions.each do |condition|
        notification = Notification.new(condition)
        notification.instance_eval(&block)

        @notifications[condition] = notification
      end
    end
817350
def notify(self, topic, **kwargs):
        '''
        
        '''
        kwargs['name'] = self._name
        self._engine._notify(topic, **kwargs)
764225
def open_notified_class
      class_eval do
        prepend NotificationActions
        attr_accessor :message, :notify_flag

        # Define association for the notified model
        has_many :notifications, class_name: 'SimpleNotifications::Record', as: :entity
        has_many :notifiers, through: :notifications, source: :sender, source_type: sender_class(@@options[:sender]).to_s
        has_many :read_deliveries, through: :notifications, source: :read_deliveries
        has_many :unread_deliveries, through: :notifications, source: :unread_deliveries

        # Callbacks
        after_create_commit :create_notification, if: proc {@@options[:callbacks].include?(:create)}
        after_update_commit :update_notification, if: proc {@@options[:callbacks].include?(:update)}
        after_destroy_commit :destroy_notification, if: proc {@@options[:callbacks].include?(:destroy)}

        NotificationActions.module_eval do
          @@options[:actions].each do |action|
            define_method(action) do
              run_callbacks action do
                super()
              end
            end

            define_method("before_#{action}".to_sym) do
            end

            define_method("after_#{action}".to_sym) do
              self.notify(sender: @@options[:sender], receivers: @@options[:receivers], message: default_message(self, @@options[:sender], action.to_s))
            end
          end
        end

        @@options[:actions].each do |action|
          define_model_callbacks action
          send("before_#{action}", "before_#{action}".to_sym)
          send("after_#{action}", "after_#{action}".to_sym)
        end

        #Example
        #post.notify(sender: :author, receivers: :followers, message: 'My Custom logic message')
        #post.create(content: '', notify: false) -> It does not create the notification.
        def notify(options = {})
          options[:sender] ||= @@options[:sender]
          options[:receivers] ||= @@options[:receivers]
          if notify_flag.nil? || (!notify_flag.nil? && !!notify_flag)
            raise 'SimpleNotification::SenderReceiverError' unless @@options[:sender] && @@options[:receivers]
            @message = options[:message] if options[:message]
            notification = notifications.build(entity: self, sender: get_obj(options[:sender]), message: default_message(self, get_obj(options[:sender]), 'created'))
            get_obj(options[:receivers]).each {|receiver| notification.deliveries.build(receiver: receiver)}
            notification.save
          end
        end

        def flush_notifications
          notifications.destroy_all
        end

        # Check if notifications has already been delivered.
        def notified?
          !notifications.blank?
        end

        def notificants
          SimpleNotifications::Record.includes(deliveries: :receiver)
              .collect(&:deliveries).flatten
              .collect(&:receiver)
        end

        def read_marked_notificants
          SimpleNotifications::Record.includes(deliveries: :receiver)
              .collect(&:deliveries).flatten
              .select{|record| record.is_read}
              .collect(&:receiver)
        end

        def unread_marked_notificants
          SimpleNotifications::Record.includes(deliveries: :receiver)
              .collect(&:deliveries).flatten
              .select{|record| !record.is_read}.collect(&:receiver)
        end

        # Mark notifications in read mode.
        # If notificants are provided then only those respective notifications will be marked read.
        # Else all will be marked as read.
        def mark_read(notificants = nil)
          (notificants ? unread_deliveries.where(receiver: notificants) : unread_deliveries).update_all(is_read: true)
        end

        # Mark notifications in unread mode.
        # If notificants are provided then only those respective notifications will be marked unread.
        # Else all will be marked as unread.
        def mark_unread(notificants = nil)
          (notificants ? read_deliveries.where(receiver: notificants) : read_deliveries).update_all(is_read: false)
        end

        def default_message(entity, sender, action)
          @message || (method(@@options[:notify_message]).call if !!@@options[:notify_message]) || "#{get_obj(sender).class.name} #{action} #{entity.class.name} #{entity.name}."
        end

        private

        def get_obj(sender_or_receivers)
          sender_or_receivers.kind_of?(Symbol) ? send(sender_or_receivers) : sender_or_receivers
        end

        def create_notification
          notify({sender: get_obj(@@options[:sender]), receivers: get_obj(@@options[:receivers]), message: default_message(self, get_obj(@@options[:sender]), 'created')})
        end

        def update_notification
          notify({sender: get_obj(@@options[:sender]), receivers: get_obj(@@options[:receivers]), message: default_message(self, get_obj(@@options[:sender]), 'updated')})
        end

        def destroy_notification
          notify({sender: get_obj(@@options[:sender]), receivers: get_obj(@@options[:receivers]), message: default_message(self, get_obj(@@options[:sender]), 'deleted')})
        end
      end
    end
638465
@Nonnull
    public String newPciAddresses(@Nonnegative int count, @Nonnull String separator) {
        StringBuilder buf = new StringBuilder();
        for (int i = 0; i < count; i++) {
            if (i > 0)
                buf.append(separator);
            buf.append(newPciAddress());
        }
        return buf.toString();
    }
947658
def create_project(self, name, description):
        
        self._cache_project_list_once()
        if name in [project.name for project in self.projects]:
            raise DuplicateNameError("There is already a project named {}".format(name))
        self.client.create_project(name, description)
        self.clear_project_cache()
        return name
930418
def add_project_name_arg(arg_parser, required, help_text):
    
    arg_parser.add_argument("-p", '--project-name',
                            metavar='ProjectName',
                            type=to_unicode,
                            dest='project_name',
                            help=help_text,
                            required=required)
296913
def project_list(self, limit=None):
        
        params = {}
        if limit:
            params['limit'] = limit
        return (self.get('rest/api/1.0/projects', params=params) or {}).get('values')
86750
function (project_data, cb) {

            _util.buildQuery('projects', project_data, function (error, data) {

                return cb(error, data);

            });

        }
195774
private List<String> splitOperation(String pOperation) {
        List<String> ret = new ArrayList<String>();
        Pattern p = Pattern.compile("^(.*)\\((.*)\\)$");
        Matcher m = p.matcher(pOperation);
        if (m.matches()) {
            ret.add(m.group(1));
            if (m.group(2).length() > 0) {
                // No escaping required since the parts a Java types which does not
                // allow for commas
                String[] args = m.group(2).split("\\s*,\\s*");
                ret.addAll(Arrays.asList(args));
            } else {
                // It's "()" which means a no-arg method
                ret.add(null);
            }
        } else {
            ret.add(pOperation);
        }
        return ret;
    }