# eric7.WebBrowser.AdBlock.AdBlockSubscription

Module implementing the AdBlock subscription class.

### Global Attributes

None

### Classes

AdBlockSubscription | Class implementing the AdBlock subscription.

### Functions

None

## AdBlockSubscription

Class implementing the AdBlock subscription.

### Signals

changed()
  emitted after the subscription has changed
enabledChanged(bool)
  emitted after the enabled state was changed
rulesChanged()
  emitted after the subscription's rules have changed
rulesEnabledChanged()
  emitted after a rule enabled state was changed

### Derived from

QObject

### Class Attributes

None

### Class Methods

None

### Methods

AdBlockSubscription | Constructor
__loadRules | Private method to load the rules of the subscription.
__parseUrl | Private method to parse the AdBlock URL for the subscription.
__rulesDownloaded | Private slot to deal with the downloaded rules.
__validateCheckSum | Private method to check the subscription file's checksum.
addRule | Public method to add a rule.
allRules | Public method to get the list of rules.
canBeRemoved | Public method to check, if the subscription can be removed.
canEditRules | Public method to check, if rules can be edited.
checkForUpdate | Public method to check for an update.
isEnabled | Public method to check, if the subscription is enabled.
lastUpdate | Public method to get the date and time of the last update.
location | Public method to get the subscription location.
removeRule | Public method to remove a rule given the offset.
replaceRule | Public method to replace a rule given the offset.
requiresLocation | Public method to get the location of a required subscription.
rule | Public method to get a specific rule.
rulesFileName | Public method to get the name of the rules file.
saveRules | Public method to save the subscription rules.
setEnabled | Public method to set the enabled status.
setLocation | Public method to set the subscription location.
setRuleEnabled | Public method to enable a specific rule.
setTitle | Public method to set the subscription title.
title | Public method to get the subscription title.
updateNow | Public method to update the subscription immediately.
url | Public method to generate the URL for this subscription.

### Static Methods

None

#### AdBlockSubscription (Constructor)

AdBlockSubscription(url, custom, parent=None, default=False)

Constructor

url
  AdBlock URL for the subscription (QUrl)
custom
  flag indicating a custom subscription (boolean)
parent
  reference to the parent object (QObject)
default
  flag indicating a default subscription (boolean)

#### AdBlockSubscription.__loadRules

__loadRules()

Private method to load the rules of the subscription.

#### AdBlockSubscription.__parseUrl

__parseUrl(url)

Private method to parse the AdBlock URL for the subscription.

url (QUrl)
  AdBlock URL for the subscription

#### AdBlockSubscription.__rulesDownloaded

__rulesDownloaded(reply)

Private slot to deal with the downloaded rules.

reply (QNetworkReply)
  reference to the network reply

#### AdBlockSubscription.__validateCheckSum

__validateCheckSum(fileName)

Private method to check the subscription file's checksum.

fileName (str)
  name of the file containing the subscription

Return:
  flag indicating a valid file. A file is considered valid, if the checksum is OK, the file does not contain a checksum (i.e. cannot be checked) or we are using the limited EasyList (because we fiddled with the original).

Return Type:
  bool

#### AdBlockSubscription.addRule

addRule(rule)

Public method to add a rule.

rule (AdBlockRule)
  reference to the rule to add

Return:
  offset of the rule

Return Type:
  int

#### AdBlockSubscription.allRules

allRules()

Public method to get the list of rules.

Return:
  list of rules

Return Type:
  list of AdBlockRule

#### AdBlockSubscription.canBeRemoved

canBeRemoved()

Public method to check, if the subscription can be removed.

Return:
  flag indicating removal is allowed

Return Type:
  bool

#### AdBlockSubscription.canEditRules

canEditRules()

Public method to check, if rules can be edited.

Return:
  flag indicating rules may be edited

Return Type:
  bool

#### AdBlockSubscription.checkForUpdate

checkForUpdate()

Public method to check for an update.

#### AdBlockSubscription.isEnabled

isEnabled()

Public method to check, if the subscription is enabled.

Return:
  flag indicating the enabled status

Return Type:
  bool

#### AdBlockSubscription.lastUpdate

lastUpdate()

Public method to get the date and time of the last update.

Return:
  date and time of the last update

Return Type:
  QDateTime

#### AdBlockSubscription.location

location()

Public method to get the subscription location.

Return:
  URL of the subscription location

Return Type:
  QUrl

#### AdBlockSubscription.removeRule

removeRule(offset)

Public method to remove a rule given the offset.

offset (int)
  offset of the rule to remove

#### AdBlockSubscription.replaceRule

replaceRule(rule, offset)

Public method to replace a rule given the offset.

rule (AdBlockRule)
  reference to the rule to set
offset (int)
  offset of the rule to remove

Return:
  requested rule

Return Type:
  AdBlockRule

#### AdBlockSubscription.requiresLocation

requiresLocation()

Public method to get the location of a required subscription.

Return:
  location of a required subscription

Return Type:
  str

#### AdBlockSubscription.rule

rule(offset)

Public method to get a specific rule.

offset (int)
  offset of the rule

Return:
  requested rule

Return Type:
  AdBlockRule

#### AdBlockSubscription.rulesFileName

rulesFileName()

Public method to get the name of the rules file.

Return:
  name of the rules file

Return Type:
  str

#### AdBlockSubscription.saveRules

saveRules()

Public method to save the subscription rules.

#### AdBlockSubscription.setEnabled

setEnabled(enabled)

Public method to set the enabled status.

enabled (bool)
  flag indicating the enabled status

#### AdBlockSubscription.setLocation

setLocation(url)

Public method to set the subscription location.

url (QUrl)
  URL of the subscription location

#### AdBlockSubscription.setRuleEnabled

setRuleEnabled(offset, enabled)

Public method to enable a specific rule.

offset (int)
  offset of the rule
enabled (bool)
  new enabled state

Return:
  reference to the changed rule

Return Type:
  AdBlockRule

#### AdBlockSubscription.setTitle

setTitle(title)

Public method to set the subscription title.

title (str)
  subscription title

#### AdBlockSubscription.title

title()

Public method to get the subscription title.

Return:
  subscription title

Return Type:
  string

#### AdBlockSubscription.updateNow

updateNow()

Public method to update the subscription immediately.

#### AdBlockSubscription.url

url()

Public method to generate the URL for this subscription.

Return:
  AdBlock URL for the subscription

Return Type:
  QUrl

Up